Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPM version check for tip #1193

Merged
merged 5 commits into from
Feb 24, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea/
.vscode/
node_modules/
build
.DS_Store
Expand Down
19 changes: 19 additions & 0 deletions packages/create-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function install(dependencies, verbose, callback) {
command = 'yarnpkg';
args = [ 'add', '--exact'].concat(dependencies);
} else {
checkNpmVersion();
command = 'npm';
args = ['install', '--save', '--save-exact'].concat(dependencies);
}
Expand Down Expand Up @@ -230,6 +231,24 @@ function getPackageName(installPackage) {
return installPackage;
}

function checkNpmVersion() {
// Check npm version
var npmVersionProc = spawn.sync('npm', ['--version']),
npmVersion = npmVersionProc.stdout;

if (npmVersion) {
var recommendVersion = semver.lt(npmVersion.toString(), '3.0.0');
if (recommendVersion) {
console.log(
chalk.green(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this yellow instead? I think we can remove the "Tip:" prefix.
Formatting wise, I would prefer

console.log(chalk.yellow(...));
console.log(chalk.yellow(...));

for each line and then another

console.log();

for a new line at the very end.

Thanks!

'Tip: It looks like you are using npm 2.\n' +
'We suggest using npm 3 or Yarn for faster install times and less disk space usage.'
)
);
}
}
}

function checkNodeVersion(packageName) {
var packageJsonPath = path.resolve(
process.cwd(),
Expand Down
2 changes: 1 addition & 1 deletion packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@
"optionalDependencies": {
"fsevents": "1.0.17"
}
}
}