add npm check to babel-doctor

This commit is contained in:
Sebastian McKenzie 2015-11-03 19:13:46 +00:00
parent 30311d121e
commit 1c3b4aa410
4 changed files with 19 additions and 1 deletions

View File

@ -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",

View File

@ -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"));

View File

@ -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";

View 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"]);
}
});
});
}