Skip to content

Commit

Permalink
Merge branch 'master' into feat/issue_11571
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jan 18, 2021
2 parents fd1a6d1 + ed60667 commit 1e988a1
Show file tree
Hide file tree
Showing 600 changed files with 23,147 additions and 8,766 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Expand Up @@ -96,7 +96,8 @@ module.exports = {
"jest/globals": true
},
globals: {
nsObj: false
nsObj: false,
jasmine: false
}
}
]
Expand Down
37 changes: 26 additions & 11 deletions bin/webpack.js
Expand Up @@ -41,6 +41,19 @@ const isInstalled = packageName => {
}
};

/**
* @param {CliOption} cli options
* @returns {void}
*/
const runCli = cli => {
const path = require("path");
const pkgPath = require.resolve(`${cli.package}/package.json`);
// eslint-disable-next-line node/no-missing-require
const pkg = require(pkgPath);
// eslint-disable-next-line node/no-missing-require
require(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName]));
};

/**
* @typedef {Object} CliOption
* @property {string} name display name
Expand Down Expand Up @@ -69,15 +82,22 @@ if (!cli.installed) {

console.error(notify);

const isYarn = fs.existsSync(path.resolve(process.cwd(), "yarn.lock"));
let packageManager;

if (fs.existsSync(path.resolve(process.cwd(), "yarn.lock"))) {
packageManager = "yarn";
} else if (fs.existsSync(path.resolve(process.cwd(), "pnpm-lock.yaml"))) {
packageManager = "pnpm";
} else {
packageManager = "npm";
}

const packageManager = isYarn ? "yarn" : "npm";
const installOptions = [isYarn ? "add" : "install", "-D"];
const installOptions = [packageManager === "yarn" ? "add" : "install", "-D"];

console.error(
`We will use "${packageManager}" to install the CLI via "${packageManager} ${installOptions.join(
" "
)}".`
)} ${cli.package}".`
);

const question = `Do you want to install 'webpack-cli' (yes/no): `;
Expand Down Expand Up @@ -116,18 +136,13 @@ if (!cli.installed) {

runCommand(packageManager, installOptions.concat(cli.package))
.then(() => {
require(cli.package); //eslint-disable-line
runCli(cli);
})
.catch(error => {
console.error(error);
process.exitCode = 1;
});
});
} else {
const path = require("path");
const pkgPath = require.resolve(`${cli.package}/package.json`);
// eslint-disable-next-line node/no-missing-require
const pkg = require(pkgPath);
// eslint-disable-next-line node/no-missing-require
require(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName]));
runCli(cli);
}
6 changes: 5 additions & 1 deletion cspell.json
Expand Up @@ -181,6 +181,8 @@
"destructure",
"onconnect",
"nwjs",
"redeclaration",
"kaios",

"webassemblyjs",
"fsevents",
Expand Down Expand Up @@ -218,7 +220,9 @@
"codecov",
"opencollective",
"dependabot",
"browserslist"
"browserslist",
"samsunginternet",
"pnpm"
],
"ignoreRegExpList": ["/Author.+/", "/data:.*/", "/\"mappings\":\".+\"/"],
"ignorePaths": ["**/dist/**", "examples/**/README.md"]
Expand Down
9 changes: 6 additions & 3 deletions declarations.d.ts
Expand Up @@ -234,6 +234,7 @@ declare module "@webassemblyjs/ast" {
args: string[];
result: string[];
}
export function moduleContextFromModuleAST(ast: any): any;

// Node matcher
export function isGlobalType(n: Node): boolean;
Expand All @@ -243,7 +244,7 @@ declare module "@webassemblyjs/ast" {
}

declare module "webpack-sources" {
type MapOptions = { columns?: boolean; module?: boolean };
export type MapOptions = { columns?: boolean; module?: boolean };

export abstract class Source {
size(): number;
Expand Down Expand Up @@ -299,15 +300,17 @@ declare module "webpack-sources" {
name: string,
sourceMap: Object | string | Buffer,
originalSource?: string | Buffer,
innerSourceMap?: Object | string | Buffer
innerSourceMap?: Object | string | Buffer,
removeOriginalSource?: boolean
);

getArgsAsBuffers(): [
Buffer,
string,
Buffer,
Buffer | undefined,
Buffer | undefined
Buffer | undefined,
boolean
];
}

Expand Down
1 change: 1 addition & 0 deletions declarations.test.d.ts
@@ -1,4 +1,5 @@
declare module "*.json";
declare module "mini-css-extract-plugin";

declare namespace jest {
interface Matchers<R> {
Expand Down

0 comments on commit 1e988a1

Please sign in to comment.