Skip to content

Commit e9d426d

Browse files
committedMay 30, 2019
chore: format and revise code w.r.t style
1 parent 5a0952e commit e9d426d

File tree

5 files changed

+46
-38
lines changed

5 files changed

+46
-38
lines changed
 

‎bin/opencollective.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ function printBadge() {
2626
print(`Please consider donating to our ${chalk.bold.blue("Open Collective")}`);
2727
print("to help us maintain this package.");
2828
console.log("\n\n");
29-
print(`${emoji("👉")} ${chalk.bold.yellow(" Donate:")} ${chalk.reset.underline.yellow("https://opencollective.com/webpack/donate")}`);
29+
print(
30+
`${emoji("👉")} ${chalk.bold.yellow(" Donate:")} ${chalk.reset.underline.yellow(
31+
"https://opencollective.com/webpack/donate"
32+
)}`
33+
);
3034
console.log("\n");
3135
}
3236

‎bin/utils/prompt-command.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ const npmGlobalRoot = () => {
3131
const cp = require("child_process");
3232
return new Promise((resolve, reject) => {
3333
const command = cp.spawn("npm", ["root", "-g"]);
34-
command.on("error", (error) => reject(error));
35-
command.stdout.on("data", (data) => resolve(data.toString()));
36-
command.stderr.on("data", (data) => reject(data));
34+
command.on("error", error => reject(error));
35+
command.stdout.on("data", data => resolve(data.toString()));
36+
command.stderr.on("data", data => reject(data));
3737
});
3838
};
3939

4040
const runWhenInstalled = (packages, pathForCmd, ...args) => {
4141
const package = require(pathForCmd);
4242
const func = package.default;
43-
if (typeof func !== 'function') {
43+
if (typeof func !== "function") {
4444
throw new Error(`@webpack-cli/${packages} failed to export a default function`);
4545
}
4646
return func(...args);
47-
}
47+
};
4848

4949
module.exports = function promptForInstallation(packages, ...args) {
5050
const nameOfPackage = "@webpack-cli/" + packages;
@@ -102,19 +102,18 @@ module.exports = function promptForInstallation(packages, ...args) {
102102
case "y":
103103
case "yes":
104104
case "1": {
105-
106105
runCommand(packageManager, options)
107-
.then(_=> {
106+
.then(_ => {
108107
if (packages === "init") {
109108
npmGlobalRoot()
110-
.then((root) => {
109+
.then(root => {
111110
const pathtoInit = path.resolve(root.trim(), "@webpack-cli", "init");
112111
return pathtoInit;
113112
})
114-
.then((pathForInit) => {
113+
.then(pathForInit => {
115114
return require(pathForInit).default(...args);
116115
})
117-
.catch((error) => {
116+
.catch(error => {
118117
console.error(error);
119118
process.exitCode = 1;
120119
});

‎package-lock.json

+30-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
"clean:all": "rimraf node_modules packages/*/{node_modules}",
3434
"commit": "git-cz",
3535
"docs": "typedoc",
36-
"format": "prettier-eslint ./bin/*.js ./test/**/*.js ./packages/**/*.js --write",
37-
"lint:codeOnly": "eslint \"{bin}/**/!(__testfixtures__)/*.js\" \"{bin}/**.js\"",
36+
"format": "prettier-eslint ./bin/*.js ./bin/**/*.js ./test/**/*.js ./packages/**/*.js ./packages/**/**/*.js --write",
3837
"lint": "eslint \"./bin/*.js\" \"./test/**/*.js\" \"packages/**/!(node_modules)/*.test.js\"",
3938
"postinstall": "node ./bin/opencollective.js",
4039
"pretest": "npm run build && npm run lint && npm run tslint",

‎packages/utils/path-utils.ts

+1-14
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,14 @@ export function isLocalPath(str: string): boolean {
1717
return path.isAbsolute(str) || /^\./.test(str) || fs.existsSync(str);
1818
}
1919

20-
/**
21-
* Get absolute path of a webpack config in a project.
22-
*
23-
* @param {String[]} str - array of extensions to look for.
24-
* @returns {String} Absolute path of the config.
25-
*/
26-
27-
export function webpackConfigPath(extensions: string[]): string {
28-
const defaultConfigFileNames = ["webpack.config", "webpackfile"].join("|");
29-
const webpackConfigFileRegExp = `(${defaultConfigFileNames})(${extensions.join("|")})`;
30-
return findup(webpackConfigFileRegExp);
31-
}
32-
3320
/**
3421
* Find the root directory path of a project.
3522
*
3623
* @returns {String} Absolute path of the project root.
3724
*/
3825

3926
export function findProjectRoot(): string {
40-
const rootFilePath = findup(`package.json`);
27+
const rootFilePath = findup("package.json");
4128
const projectRoot = path.dirname(rootFilePath);
4229
return projectRoot;
4330
}

0 commit comments

Comments
 (0)
Please sign in to comment.