Skip to content

Commit

Permalink
checks if babel is installed globally and displays correct cli message (
Browse files Browse the repository at this point in the history
#5258)

* checks if babel is installed globally and displays correct cli message - fixes #5228

* recommend local installation and fix lint errors

* uses babel-cli vs babel

* switch back to babel

* use process.cwd() to determine if globally executed

* checks for /node_module/.bin/babel

* compare execPath and module execution path to determine global or local installation

* Move the babel/cli.js into a 'src' so the 'const's are compiled Node < 6.
  • Loading branch information
xtina-starr authored and existentialism committed May 19, 2017
1 parent c2d740d commit dfb9cda
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/babel/package.json
Expand Up @@ -7,8 +7,8 @@
"license": "MIT",
"repository": "https://github.com/babel/babel/tree/master/packages/babel",
"bin": {
"babel": "./cli.js",
"babel-node": "./cli.js",
"babel-external-helpers": "./cli.js"
"babel": "./lib/cli.js",
"babel-node": "./lib/cli.js",
"babel-external-helpers": "./lib/cli.js"
}
}
7 changes: 5 additions & 2 deletions packages/babel/cli.js → packages/babel/src/cli.js
@@ -1,10 +1,13 @@
#!/usr/bin/env node
import path from "path";

const globalMessage = path.dirname(process.execPath) === path.dirname(process.env._ || "") ? " -g" : "";

console.error("You have mistakenly installed the `babel` package, which is a no-op in Babel 6.\n" +
"Babel's CLI commands have been moved from the `babel` package to the `babel-cli` package.\n" +
"\n" +
" npm uninstall babel\n" +
" npm install babel-cli\n" +
" npm uninstall" + globalMessage + " babel\n" +
" npm install --save-dev babel-cli\n" +
"\n" +
"See http://babeljs.io/docs/usage/cli/ for setup instructions.");
process.exit(1);

0 comments on commit dfb9cda

Please sign in to comment.