Set the exit code to 1 when webpack-cli is not installed
This ensures that if the callback function is not excuted, the script will exit with a failure, as it should. If the user wishes to install webpack-cli, we clear the exit code from inside the callback function.
This commit is contained in:
parent
0ddecfa7f7
commit
7ed8023a05
|
@ -87,15 +87,10 @@ if (!cli.installed) {
|
|||
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);
|
||||
}
|
||||
// In certain scenarios (e.g. when STDIN is not in terminal mode), the callback function will not be
|
||||
// executed. Setting the exit code here to ensure the script exits correctly in those cases. The callback
|
||||
// function is responsible for clearing the exit code if the user wishes to install webpack-cli.
|
||||
process.exitCode = 1;
|
||||
questionInterface.question(question, answer => {
|
||||
questionInterface.close();
|
||||
|
||||
|
@ -106,10 +101,10 @@ if (!cli.installed) {
|
|||
"You need to install 'webpack-cli' to use webpack via CLI.\n" +
|
||||
"You can also install the CLI manually."
|
||||
);
|
||||
process.exitCode = 1;
|
||||
|
||||
return;
|
||||
}
|
||||
process.exitCode = 0;
|
||||
|
||||
console.log(
|
||||
`Installing '${
|
||||
|
|
Loading…
Reference in New Issue