`fly.clear` is executed early / not awaited
See original GitHub issueversions:
Platform: Arch Linux 4.6.5-1-zen x86_64 latest Node: v6.4.0 Fly version: 1.3.1
Itβs a little hard to describe the issue. First of all, I will explain what the sample contains. And then I describe the operations and whatβs weird.
sample project
The repo is here: https://github.com/frantic1048/fly-issue-193
overall sturcture:
.
βββ dist // output path
βββ flyfile.js
βββ node_modules
βββ package.json
βββ src // source path
βββ a
β βββ a1.txt
β βββ a2.txt
β βββ a3.txt
β βββ a4.txt
βββ b
βββ b1.txt
βββ b2.txt
βββ b3.txt
βββ b4.txt
flyfile.js : just some copy/paste tasks and a clean task, and two top-level task to run tasks in serial/parallel.
const paths = {
a: {
source: 'src/a/*.txt',
target: 'dist/a'
},
b: {
source: 'src/b/*.txt',
target: 'dist/b'
},
all: {target: 'dist'}
}
exports.clean = function * () {
yield this.clear(paths.all.target)
}
exports.a = function * () {
yield this
.source(paths.a.source)
.target(paths.a.target)
}
exports.b = function * () {
yield this
.source(paths.b.source)
.target(paths.b.target)
}
exports.serial = function * () {
yield this.start('clean')
yield this.start('a')
yield this.start('b')
}
exports.parallel = function * () {
yield this.start('clean')
yield this.start(['a', 'b'], {parallel: true})
}
package.json : the only dependency is fly, just npm i
to install it.
{
"name": "fly-missing-file",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"cc": "fly clean",
"s": "DEBUG=\"fly*\" fly serial",
"p": "DEBUG=\"fly*\" fly parallel"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"fly": "^1.3.1"
}
}
.txt : every .txt file is just Lorem ipsum . Other content also is ok.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam, iste, iure, quod voluptates soluta quidem commodi animi recusandae unde obcaecati amet eaque facere similique. Necessitatibus, iusto possimus minima numquam modi.
reproducing operation
Ensure you have runned npm install
to get the dependencies ready.
Now, the dist
folder is empty, we run paralleled task.
npm run p
Then dist
becomes:
dist/
βββ a
β βββ a1.txt
β βββ a2.txt
β βββ a3.txt
β βββ a4.txt
βββ b
βββ b1.txt
βββ b2.txt
βββ b3.txt
βββ b4.txt
Every thing works great. Then we run the paralled task the second time.
npm run p
Then whole dist
disappeared, even the dist
folder itself. While debug log shows all the *.txt were written.
We can type npm run p
again, then all the files are back. This time we delete some of the output file:
dist/
βββ a
β βββ a1.txt
β βββ a2.txt
βββ b
βββ b4.txt
Then type npm run p
, we get:
dist/
βββ a
β βββ a3.txt
β βββ a4.txt
βββ b
βββ b1.txt
βββ b2.txt
βββ b3.txt
It just like all the output are βinvertedβ, this situation also happens replacing all the npm run p
by npm run s
(serial version).
And every time running npm run p
, the debug log shows every output file was written, log like:
[frantic@RabbitHouseCafe fly-missing-file]$ npm run p
> fly-missing-file@1.0.0 p /home/frantic/work/demoo/fly-missing-file
> DEBUG="fly*" fly parallel
fly:find find this file: flyfile.js +0ms
fly:plugins beginning to look for plugins +5ms
fly:find find this file: package.json +1ms
fly:read read this file: /home/frantic/work/demoo/fly-missing-file/package.json +0ms
fly:plugins parse fly-* plugins from `package.json` +2ms
fly chdir '/home/frantic/work/demoo/fly-missing-file' +1ms
fly:log Flying with /home/frantic/work/demoo/fly-missing-file/flyfile.js... +2ms
fly start [ 'parallel' ] in sequence +0ms
fly run 'parallel' +2ms
fly:log Starting parallel +0ms
fly start [ 'clean' ] in sequence +0ms
fly run 'clean' +0ms
fly:log Starting clean +0ms
fly clear [ 'dist' ] +0ms
fly:log Finished clean in 4 ms +4ms
fly start [ 'a', 'b' ] in parallel +0ms
fly run 'a' +0ms
fly:log Starting a +0ms
fly source [ 'src/a/*.txt' ] +0ms
fly run 'b' +3ms
fly:log Starting b +0ms
fly source [ 'src/b/*.txt' ] +0ms
fly:read read this file: src/a/a1.txt +6ms
fly:read read this file: src/a/a2.txt +0ms
fly:read read this file: src/a/a3.txt +0ms
fly:read read this file: src/a/a4.txt +0ms
fly:read read this file: src/b/b1.txt +1ms
fly:read read this file: src/b/b2.txt +0ms
fly:read read this file: src/b/b3.txt +0ms
fly:read read this file: src/b/b4.txt +0ms
fly:write write this file: dist/a/a1.txt +2ms
fly:write write this file: dist/a/a2.txt +1ms
fly:write write this file: dist/a/a3.txt +0ms
fly:write write this file: dist/a/a4.txt +0ms
fly:log Finished a in 13 ms +0ms
fly:write write this file: dist/b/b1.txt +1ms
fly:write write this file: dist/b/b2.txt +0ms
fly:write write this file: dist/b/b3.txt +0ms
fly:write write this file: dist/b/b4.txt +0ms
fly:log Finished b in 11 ms +0ms
fly:log Finished parallel in 18 ms +1ms
i.e. I havenβt seen any file to output is missing in the log.
Sorry for such long text ~(>_<~)
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (9 by maintainers)
Top GitHub Comments
@frantic1048 Solved π Will ship with version 1.4, coming shortly
Yeah π annoying issue; thanks for your patience!
Iβll have some time to look at it tonight.