Skip to content

Commit 74fb759

Browse files
committed
fix(monorepo): fix lint errors
1 parent 5f357c9 commit 74fb759

File tree

2 files changed

+55
-54
lines changed

2 files changed

+55
-54
lines changed

bin/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
});
4242

4343
if (NON_COMPILATION_CMD) {
44-
return require('./prompt-command')(NON_COMPILATION_CMD, ...process.argv);
44+
return require("./prompt-command")(NON_COMPILATION_CMD, ...process.argv);
4545
}
4646

4747
const yargs = require("yargs").usage(`webpack-cli ${

bin/prompt-command.js

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,63 @@
11
// based on https://github.com/webpack/webpack/blob/master/bin/webpack.js
2-
module.exports = function promptForInstallation(package, ...args) {
2+
module.exports = function promptForInstallation(packages, ...args) {
33

4-
let packageIsInstalled = false;
5-
try {
6-
require.resolve(package);
7-
packageIsInstalled = true;
8-
} catch (err) {
9-
packageIsInstalled = false;
10-
}
4+
let packageIsInstalled = false;
5+
try {
6+
require.resolve(packages);
7+
packageIsInstalled = true;
8+
} catch (err) {
9+
packageIsInstalled = false;
10+
}
1111

12-
if (!packageIsInstalled) {
13-
const path = require("path");
14-
const fs = require("fs");
15-
const readLine = require("readline");
16-
const isYarn = fs.existsSync(path.resolve(process.cwd(), "yarn.lock"));
12+
if (!packageIsInstalled) {
13+
const path = require("path");
14+
const fs = require("fs");
15+
const readLine = require("readline");
16+
const isYarn = fs.existsSync(path.resolve(process.cwd(), "yarn.lock"));
1717

18-
const packageManager = isYarn ? "yarn" : "npm";
19-
const options = ["install", "-D", package];
18+
const packageManager = isYarn ? "yarn" : "npm";
19+
const options = ["install", "-D", packages];
2020

21-
if (isYarn) {
22-
options[0] = "add";
23-
}
21+
if (isYarn) {
22+
options[0] = "add";
23+
}
2424

25-
const commandToBeRun = `${packageManager} ${options.join(" ")}`;
25+
const commandToBeRun = `${packageManager} ${options.join(" ")}`;
2626

27-
const question = `Would you like to install ${package}? (That will run ${commandToBeRun}) (yes/NO)`;
27+
const question = `Would you like to install ${packages}? (That will run ${commandToBeRun}) (yes/NO)`;
2828

29-
console.error(`The command moved into a separate package: @webpack-cli/${package}`);
30-
const questionInterface = readLine.createInterface({
31-
input: process.stdin,
32-
output: process.stdout
33-
});
34-
questionInterface.question(question, answer => {
35-
questionInterface.close();
36-
switch (answer.toLowerCase()) {
37-
case "y":
38-
case "yes":
39-
case "1": {
40-
runCommand(packageManager, options)
41-
.then(result => {
42-
return require(`@webpack-cli/${package}`)(...args); //eslint-disable-line
43-
})
44-
.catch(error => {
45-
console.error(error);
46-
process.exitCode = 1;
47-
});
48-
break;
29+
console.error(`The command moved into a separate package: @webpack-cli/${packages}`);
30+
const questionInterface = readLine.createInterface({
31+
input: process.stdin,
32+
output: process.stdout
33+
});
34+
questionInterface.question(question, answer => {
35+
questionInterface.close();
36+
switch (answer.toLowerCase()) {
37+
case "y":
38+
case "yes":
39+
case "1": {
40+
//eslint-disable-next-line
41+
runCommand(packageManager, options)
42+
.then(result => {
43+
return require(`@webpack-cli/${packages}`)(...args); //eslint-disable-line
44+
})
45+
.catch(error => {
46+
console.error(error);
47+
process.exitCode = 1;
48+
});
49+
break;
50+
}
51+
default: {
52+
console.error(
53+
"It needs to be installed alongside webpack CLI to use the command"
54+
);
55+
process.exitCode = 1;
56+
break;
57+
}
4958
}
50-
default: {
51-
console.error(
52-
"It needs to be installed alongside webpack CLI to use the command"
53-
);
54-
process.exitCode = 1;
55-
break;
56-
}
57-
}
58-
});
59-
} else {
60-
require(package)(...args); // eslint-disable-line
61-
}
62-
}
59+
});
60+
} else {
61+
require(packages)(...args); // eslint-disable-line
62+
}
63+
};

0 commit comments

Comments
 (0)