Add no-babelrc option in babel-node (#5621)

<!-- 
Before making a PR please make sure to read our contributing guidelines 
https://github.com/babel/babel/blob/master/CONTRIBUTING.md

For any issue references: Add a comma-separated list of a [closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by the ticket number fixed by the PR
-->

| Q                        | A <!--(yes/no) -->
| ------------------------ | ---
| Patch: Bug Fix?          | 
| Major: Breaking Change?  | 
| Minor: New Feature?      | y
| Deprecations?            | 
| Spec Compliancy?         | 
| Tests Added/Pass?        | y/y
| Fixed Tickets            | #5616
| License                  | MIT
| Doc PR                   | <!-- if yes, add `[skip ci]` to your commit message to skip CI builds -->
| Dependency Changes       | 

<!-- Describe your changes below in as much detail as possible -->

Once merged I will make the corresponding documentation changes on the website (in a 7 branch)
This commit is contained in:
Sven SAULEAU 2018-05-23 18:19:39 +02:00 committed by Logan Smyth
parent 01d969a182
commit 52b800decb
7 changed files with 20 additions and 1 deletions

View File

@ -36,7 +36,9 @@ const readDir = function(loc, filter) {
const saveInFiles = function(files) {
// Place an empty .babelrc in each test so tests won't unexpectedly get to repo-level config.
outputFileSync(".babelrc", "{}");
if (!fs.existsSync(".babelrc")) {
outputFileSync(".babelrc", "{}");
}
Object.keys(files).forEach(function(filename) {
const content = files[filename];

View File

@ -22,6 +22,10 @@ function collect(value, previousValue): Array<string> {
}
program.option("-e, --eval [script]", "Evaluate script");
program.option(
"--no-babelrc",
"Specify whether or not to use .babelrc and .babelignore files",
);
program.option("-r, --require [module]", "Require module");
program.option("-p, --print [code]", "Evaluate script and print result");
program.option(
@ -47,6 +51,7 @@ program.usage("[options] [ -e script | script.js ] [arguments]");
program.parse(process.argv);
register({
babelrc: program.babelrc,
extensions: program.extensions,
ignore: program.ignore,
only: program.only,

View File

@ -0,0 +1,3 @@
{
"plugins": ["./logPlugin.js"]
}

View File

@ -0,0 +1 @@
console.log("foo");

View File

@ -0,0 +1,4 @@
module.exports = function () {
console.log("Plugin was loaded, shouldn't appear due to --no-babelrc");
return {}
}

View File

@ -0,0 +1,3 @@
{
"args": ["--no-babelrc", "index"]
}

View File

@ -0,0 +1 @@
foo