-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: handle multiple input sources in watch mode
- Loading branch information
Showing
14 changed files
with
136 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/babel-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/executor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const fs = require("fs"); | ||
const assert = require("assert"); | ||
|
||
// For Node.js <= 10 | ||
if (!assert.match) assert.match = (val, re) => assert(re.test(val)); | ||
|
||
const run = (function* () { | ||
assert.match(yield, /Successfully compiled 4 files with Babel \(\d+ms\)\./); | ||
|
||
// update ./module1/src/index.js | ||
fs.writeFileSync( | ||
"./module1/src/index.js", | ||
`let str = REPLACE_ME + REPLACE_ME;` | ||
); | ||
|
||
assert.match(yield, /Successfully compiled 1 file with Babel \(\d+ms\)\./); | ||
})(); | ||
|
||
run.next(); | ||
|
||
process.stdin.on("data", function listener(chunk) { | ||
const str = String(chunk).trim(); | ||
if (!str) return; | ||
|
||
console.log(str); | ||
|
||
if (run.next(str).done) { | ||
process.exit(0); | ||
} | ||
}); | ||
|
||
setTimeout(() => { | ||
console.error("EXECUTOR TIMEOUT"); | ||
process.exit(1); | ||
}, 5000); |
25 changes: 25 additions & 0 deletions
25
...abel-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/in-files/babel.config.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
function inlinePlugin(api, { filename }) { | ||
const { types: t } = api; | ||
|
||
const contents = api.cache.using(() => fs.readFileSync(filename, "utf8")); | ||
api.addExternalDependency(filename); | ||
|
||
return { | ||
visitor: { | ||
Identifier(path) { | ||
if (path.node.name === "REPLACE_ME") { | ||
path.replaceWith(t.stringLiteral(contents)); | ||
} | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
module.exports = { | ||
plugins: [ | ||
[inlinePlugin, { filename: path.resolve(__dirname, "./file.txt") }], | ||
], | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/babel-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/in-files/file.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hi :) |
1 change: 1 addition & 0 deletions
1
...-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/in-files/module1/src/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let str = REPLACE_ME; |
1 change: 1 addition & 0 deletions
1
...l-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/in-files/module1/src/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log(REPLACE_ME); |
1 change: 1 addition & 0 deletions
1
...-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/in-files/module2/src/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let str = REPLACE_ME; |
1 change: 1 addition & 0 deletions
1
...l-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/in-files/module2/src/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log(REPLACE_ME); |
6 changes: 6 additions & 0 deletions
6
packages/babel-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"args": ["*/src", "--out-dir", "../lib", "--relative", "--watch"], | ||
"noBabelrc": true, | ||
"noDefaultPlugins": true, | ||
"minNodeVersion": 8 | ||
} |
1 change: 1 addition & 0 deletions
1
...cli/test/fixtures/babel/dir --out-dir --watch multiple dir/out-files/module1/lib/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let str = "Hi :)" + "Hi :)"; |
1 change: 1 addition & 0 deletions
1
...-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/out-files/module1/lib/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log("Hi :)"); |
1 change: 1 addition & 0 deletions
1
...cli/test/fixtures/babel/dir --out-dir --watch multiple dir/out-files/module2/lib/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let str = "Hi :)"; |
1 change: 1 addition & 0 deletions
1
...-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/out-files/module2/lib/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log("Hi :)"); |
2 changes: 2 additions & 0 deletions
2
packages/babel-cli/test/fixtures/babel/dir --out-dir --watch multiple dir/stdout.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Successfully compiled 4 files with Babel (123ms). | ||
Successfully compiled 1 file with Babel (123ms). |