Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
included in all copies or substantial portions of this Source Code Form.
*/
const router = require('koa-route');
const stringify = require('safe-stable-stringify');
const stripAnsi = require('strip-ansi');

const prep = (data) => JSON.stringify(data);
const prep = (data) => stringify(data);

const statsOptions = {
all: false,
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"open": "^7.0.3",
"p-defer": "^3.0.0",
"rimraf": "^3.0.2",
"safe-stable-stringify": "^1.1.1",
"strip-ansi": "^6.0.0",
"superstruct": "^0.11.1",
"webpack-plugin-ramdisk": "^0.1.2",
Expand All @@ -77,6 +78,7 @@
"nyc": "^15.0.1",
"pre-commit": "^1.2.2",
"puppeteer": "^3.0.2",
"random-js": "^2.1.0",
"react-refresh": "^0.8.3",
"webpack": "^4.44.2",
"webpack-nano": "^1.0.0"
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/multi/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { resolve } = require('path');

const getPort = require('get-port');
const { getPort } = require('../../helpers/port');

const { WebpackPluginServe: Serve } = require('../../../lib/');

const serve = new Serve({
host: 'localhost',
port: getPort({ port: 55555 })
port: getPort()
});

module.exports = [
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/ramdisk-empty-pkg/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { resolve } = require('path');

const getPort = require('get-port');
const { getPort } = require('../../helpers/port');

const { WebpackPluginServe: Serve } = require('../../../lib/');

Expand All @@ -16,7 +16,7 @@ module.exports = {
plugins: [
new Serve({
host: 'localhost',
port: getPort({ port: 55555 }),
port: getPort(),
ramdisk: true
})
],
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/ramdisk/config-context-error.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { resolve } = require('path');

const getPort = require('get-port');
const { getPort } = require('../../helpers/port');

const { WebpackPluginServe: Serve } = require('../../../lib/');

Expand All @@ -16,7 +16,7 @@ module.exports = {
plugins: [
new Serve({
host: 'localhost',
port: getPort({ port: 55555 }),
port: getPort(),
ramdisk: true
})
],
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/ramdisk/config-cwd-error.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { resolve } = require('path');

const getPort = require('get-port');
const { getPort } = require('../../helpers/port');

const { WebpackPluginServe: Serve } = require('../../../lib/');

Expand All @@ -16,7 +16,7 @@ module.exports = {
plugins: [
new Serve({
host: 'localhost',
port: getPort({ port: 55555 }),
port: getPort(),
ramdisk: true
})
],
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/ramdisk/custom-options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { resolve } = require('path');

const getPort = require('get-port');
const { getPort } = require('../../helpers/port');

const { WebpackPluginServe: Serve } = require('../../../lib/');

Expand All @@ -16,7 +16,7 @@ module.exports = {
plugins: [
new Serve({
host: 'localhost',
port: getPort({ port: 55555 }),
port: getPort(),
ramdisk: {
bytes: 1024 * 1024
}
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/ramdisk/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { resolve } = require('path');

const getPort = require('get-port');
const { getPort } = require('../../helpers/port');

const { WebpackPluginServe: Serve } = require('../../../lib/');

Expand All @@ -16,7 +16,7 @@ module.exports = {
plugins: [
new Serve({
host: 'localhost',
port: getPort({ port: 55555 }),
port: getPort(),
ramdisk: true
})
],
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/simple/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { resolve } = require('path');

const getPort = require('get-port');
const { getPort } = require('../../helpers/port');

const { WebpackPluginServe: Serve } = require('../../../lib/');

Expand All @@ -19,7 +19,7 @@ module.exports = {
'X-Superhero': 'batman'
},
host: 'localhost',
port: getPort({ port: 55555 })
port: getPort()
})
],
resolve: {
Expand Down
8 changes: 8 additions & 0 deletions test/helpers/port.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const getPort = require('get-port');
const { Random } = require('random-js');

const random = new Random();

module.exports = {
getPort: () => getPort({ port: random.integer(55000, 55555) })
};
10 changes: 5 additions & 5 deletions test/ramdisk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const waitFor = (text, stream) => {
};
};

test('ramdisk', async (t) => {
test.serial('ramdisk', async (t) => {
const proc = execa('wp', [], { cwd: fixturePath });
const { stderr, stdout } = proc;
const pathTest = 'Build being written to ';
Expand All @@ -41,7 +41,7 @@ test('ramdisk', async (t) => {
proc.kill('SIGTERM');
});

test('ramdisk with options', async (t) => {
test.serial('ramdisk with options', async (t) => {
const proc = execa('wp', ['--config', 'ramdisk/custom-options.js'], {
cwd: resolve(fixturePath, '..')
});
Expand All @@ -62,7 +62,7 @@ test('ramdisk with options', async (t) => {
proc.kill('SIGTERM');
});

test('context error', async (t) => {
test.serial('context error', async (t) => {
try {
await execa('wp', ['--config', 'ramdisk/config-context-error.js'], {
cwd: resolve(fixturePath, '..')
Expand All @@ -75,7 +75,7 @@ test('context error', async (t) => {
t.fail();
});

test('cwd error', async (t) => {
test.serial('cwd error', async (t) => {
try {
await execa('wp', ['--config', '../config-cwd-error.js'], {
cwd: join(fixturePath, 'cwd-error')
Expand All @@ -88,7 +88,7 @@ test('cwd error', async (t) => {
t.fail();
});

test('ramdisk with empty package.json', async (t) => {
test.serial('ramdisk with empty package.json', async (t) => {
const fixturePath = join(__dirname, 'fixtures/ramdisk-empty-pkg');
const proc = execa('wp', [], { cwd: fixturePath });
const { stderr, stdout } = proc;
Expand Down
2 changes: 1 addition & 1 deletion test/wait-for-build.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const getPort = require('get-port');
const del = require('del');
const webpack = require('webpack');
const test = require('ava');
const fetch = require('node-fetch');
const defer = require('p-defer');

const { getPort } = require('./helpers/port');
const { make } = require('./fixtures/wait-for-build/make-config');

let watcher;
Expand Down
3 changes: 2 additions & 1 deletion test/ws.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const test = require('ava');
const getPort = require('get-port');
const Koa = require('koa');
const router = require('koa-route');
const defer = require('p-defer');
const WebSocket = require('ws');

const { middleware } = require('../lib/ws');

const { getPort } = require('./helpers/port');

test('websocket middleware', async (t) => {
const app = new Koa();
const port = await getPort();
Expand Down