mirror of https://github.com/webpack/webpack.git
Exit with an error if we can't prompt for webpack-cli installation.
If STDIN is not in terminal mode when the webpack script is executed, the readline module will never execute the callback passed to question and the script will exit successfully, without ever building the pack. An example of this is Rails' webpacker gem, which executes the webpack script in a subshell. If STDIN is not in terminal mode, we should exit with an error immediately, instead of attempting to ask a question to which we'll never receive an answer.
This commit is contained in:
parent
f40d05fdea
commit
542eaf9de2
|
@ -86,6 +86,16 @@ if (!cli.installed) {
|
||||||
input: process.stdin,
|
input: process.stdin,
|
||||||
output: process.stderr
|
output: process.stderr
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// If we're not in terminal mode, readline won't execute the callback function below. Return here
|
||||||
|
// so that we can set the exit code properly.
|
||||||
|
if (!questionInterface.terminal) {
|
||||||
|
console.error(
|
||||||
|
"You need to install 'webpack-cli' to use webpack via CLI.\n" +
|
||||||
|
"You can also install the CLI manually."
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
questionInterface.question(question, answer => {
|
questionInterface.question(question, answer => {
|
||||||
questionInterface.close();
|
questionInterface.close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue