add npm check to babel-doctor
This commit is contained in:
parent
30311d121e
commit
1c3b4aa410
@ -11,6 +11,7 @@
|
||||
"babel-core": "^6.0.15",
|
||||
"babel-polyfill": "^6.0.14",
|
||||
"babel-runtime": "^5.0.0",
|
||||
"bin-version-check": "^2.1.0",
|
||||
"chalk": "1.1.1",
|
||||
"chokidar": "^1.0.0",
|
||||
"commander": "^2.8.1",
|
||||
|
||||
@ -42,11 +42,13 @@ while (nodeModulesDirectories.length) {
|
||||
if (packageName[0] === ".") continue;
|
||||
|
||||
let packageLoc = path.join(loc, packageName);
|
||||
let packageJsonLoc = path.join(packageLoc, "package.json");
|
||||
if (!fs.existsSync(packageJsonLoc)) continue;
|
||||
|
||||
packages.push({
|
||||
name: packageName,
|
||||
loc: packageLoc,
|
||||
version: require(path.join(packageLoc, "package.json")).version
|
||||
version: require(packageJsonLoc).version
|
||||
});
|
||||
|
||||
nodeModulesDirectories.push(path.join(packageLoc, "node_modules"));
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
export { default as hasConfig } from "./has-config";
|
||||
export { default as deduped } from "./deduped";
|
||||
export { default as latestPackages } from "./latest-packages";
|
||||
export { default as npm } from "./npm-3";
|
||||
|
||||
14
packages/babel-cli/src/babel-doctor/rules/npm-3.js
Normal file
14
packages/babel-cli/src/babel-doctor/rules/npm-3.js
Normal file
@ -0,0 +1,14 @@
|
||||
import binVersionCheck from "bin-version-check";
|
||||
import chalk from "chalk";
|
||||
|
||||
export default function () {
|
||||
return new Promise(function (resolve) {
|
||||
binVersionCheck("npm", ">=3.3.0", function (err) {
|
||||
if (err) {
|
||||
resolve([false, `Your npm version is outdated. Upgrade to the latest version by running:\n$ ${chalk.magenta("npm install -g npm")}`]);
|
||||
} else {
|
||||
resolve([true, "You're on npm >=3.3.0"]);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user