Skip to content

Commit f139812

Browse files
authored
refactor: remove stdin option (#3111)
BREAKING CHANGE: `stdin`option was removed
1 parent ca0b534 commit f139812

File tree

7 files changed

+8
-72
lines changed

7 files changed

+8
-72
lines changed

bin/cli-flags.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,6 @@ module.exports = {
111111
'Do not close and exit the process on SIGNIT and SIGTERM.',
112112
negative: true,
113113
},
114-
{
115-
name: 'stdin',
116-
type: Boolean,
117-
configs: [
118-
{
119-
type: 'boolean',
120-
},
121-
],
122-
description: 'Close when stdin ends.',
123-
},
124114
{
125115
name: 'open',
126116
type: [Boolean, String],

lib/options.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,6 @@
349349
}
350350
]
351351
},
352-
"stdin": {
353-
"type": "boolean"
354-
},
355352
"transportMode": {
356353
"anyOf": [
357354
{
@@ -406,7 +403,6 @@
406403
"public": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserverpublic)",
407404
"setupExitSignals": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserversetupexitsignals)",
408405
"static": "should be {Boolean|String|Object|Array} (https://webpack.js.org/configuration/dev-server/#devserverstatic)",
409-
"stdin": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverstdin)",
410406
"transportMode": "should be {String|Object} (https://webpack.js.org/configuration/dev-server/#devservertransportmode)",
411407
"useLocalIp": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserveruselocalip)"
412408
}

lib/utils/setupExitSignals.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ function setupExitSignals(server) {
2020
process.on(signal, closeAndExit);
2121
});
2222
}
23-
24-
if (server.options.stdin) {
25-
process.stdin.on('end', closeAndExit);
26-
process.stdin.resume();
27-
}
2823
}
2924

3025
module.exports = setupExitSignals;

test/__snapshots__/Validation.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ exports[`Validation validation should fail validation for invalid \`hot\` config
1212
exports[`Validation validation should fail validation for invalid \`injectHot\` configuration 1`] = `
1313
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
1414
- configuration has an unknown property 'injectHot'. These properties are valid:
15-
object { bonjour?, client?, compress?, dev?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, openPage?, port?, proxy?, public?, setupExitSignals?, static?, stdin?, transportMode?, useLocalIp? }"
15+
object { bonjour?, client?, compress?, dev?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, openPage?, port?, proxy?, public?, setupExitSignals?, static?, transportMode?, useLocalIp? }"
1616
`;
1717
1818
exports[`Validation validation should fail validation for invalid \`static\` configuration 1`] = `
@@ -31,5 +31,5 @@ exports[`Validation validation should fail validation for invalid \`static\` con
3131
exports[`Validation validation should fail validation for no additional properties 1`] = `
3232
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
3333
- configuration has an unknown property 'additional'. These properties are valid:
34-
object { bonjour?, client?, compress?, dev?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, openPage?, port?, proxy?, public?, setupExitSignals?, static?, stdin?, transportMode?, useLocalIp? }"
34+
object { bonjour?, client?, compress?, dev?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, openPage?, port?, proxy?, public?, setupExitSignals?, static?, transportMode?, useLocalIp? }"
3535
`;

test/cli/cli.test.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,12 @@ describe('CLI', () => {
300300
});
301301
});
302302

303-
it('should exit the process when stdin ends if --stdin', (done) => {
303+
it('should exit the process when stdin ends if --watch-options-stdin', (done) => {
304304
const cliPath = path.resolve(__dirname, '../../bin/webpack-dev-server.js');
305305
const examplePath = path.resolve(__dirname, '../../examples/cli/public');
306-
const cp = execa('node', [cliPath, '--stdin'], { cwd: examplePath });
306+
const cp = execa('node', [cliPath, '--watch-options-stdin'], {
307+
cwd: examplePath,
308+
});
307309

308310
cp.stdout.on('data', (data) => {
309311
const bits = data.toString();
@@ -321,10 +323,10 @@ describe('CLI', () => {
321323
});
322324
});
323325

324-
it('should exit the process when stdin ends if --stdin, even before the compilation is done', (done) => {
326+
it('should exit the process when stdin ends if --watch-options-stdin, even before the compilation is done', (done) => {
325327
const cliPath = path.resolve(__dirname, '../../bin/webpack-dev-server.js');
326328
const cwd = path.resolve(__dirname, '../fixtures/cli');
327-
const cp = execa('node', [cliPath, '--stdin'], { cwd });
329+
const cp = execa('node', [cliPath, '----watch-options-stdin'], { cwd });
328330

329331
let killed = false;
330332

test/server/setupExitSignals-option.test.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ describe('setupExitSignals option', () => {
1616
config,
1717
{
1818
setupExitSignals: true,
19-
stdin: true,
2019
port,
2120
},
2221
done
@@ -47,14 +46,4 @@ describe('setupExitSignals option', () => {
4746
done();
4847
}, 1000);
4948
});
50-
51-
it('should close and exit on stdin end', (done) => {
52-
process.stdin.emit('end');
53-
54-
setTimeout(() => {
55-
expect(killSpy.mock.calls.length).toEqual(1);
56-
expect(exitSpy.mock.calls.length).toEqual(1);
57-
done();
58-
}, 1000);
59-
});
6049
});

test/server/utils/setupExitSignals.test.js

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@ const setupExitSignals = require('../../../lib/utils/setupExitSignals');
55
describe('setupExitSignals', () => {
66
let server;
77
let exitSpy;
8-
let stdinResumeSpy;
98
const signals = ['SIGINT', 'SIGTERM'];
109

1110
beforeAll(() => {
1211
exitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {});
13-
stdinResumeSpy = jest
14-
.spyOn(process.stdin, 'resume')
15-
.mockImplementation(() => {});
1612
server = {
1713
close: jest.fn((callback) => {
1814
callback();
@@ -49,36 +45,4 @@ describe('setupExitSignals', () => {
4945
}, 1000);
5046
});
5147
});
52-
53-
it(`should resume stdin if stdin: true`, () => {
54-
const serverStdin = Object.assign(
55-
{
56-
options: {
57-
stdin: true,
58-
},
59-
},
60-
server
61-
);
62-
setupExitSignals(serverStdin);
63-
expect(stdinResumeSpy.mock.calls.length).toEqual(1);
64-
});
65-
66-
it(`should close server, then exit process (stdin end)`, (done) => {
67-
const serverStdin = Object.assign(
68-
{
69-
options: {
70-
stdin: true,
71-
},
72-
},
73-
server
74-
);
75-
setupExitSignals(serverStdin);
76-
process.stdin.emit('end');
77-
78-
setTimeout(() => {
79-
expect(server.close.mock.calls.length).toEqual(1);
80-
expect(exitSpy.mock.calls.length).toEqual(1);
81-
done();
82-
}, 1000);
83-
});
8448
});

0 commit comments

Comments
 (0)