taskr icon indicating copy to clipboard operation
taskr copied to clipboard

Duplication of files (in wrong dirs) when doing multiple dir copies

Open tmarshall opened this issue 7 years ago • 3 comments

I have a taskfile that has a portion like this:

module.exports.copyProcs = async function copyProcs(task) {
  await task.source('procs/**/*.js').target('dist/procs')
  await task.source('procs/**/.*').target('dist/procs')
}

module.exports.copyConf = async function copyConf(task) {
  await task.source('conf/**/.*').target('dist/conf')
}

module.exports.copyDirs = async function copyDirs(task) {
  await task.parallel(['copyProcs', 'copyConf'])
}

module.exports.build = async function build(task) {
  // compile is not necessary to show
  await task.serial(['compile', 'copyDirs'])
} 

taskr build is my yarn build

This should copy all .js files and . files (specifically .gitignore) from procs to dist/procs

It should also copy all . files (specifically .eslintrc and .jscsrc) from conf to dist/conf

When run, it is copying .eslintrc and .jscsrc to both dist/conf and dist/procs.

If I change the content of function copyDirs to await task.serial(['copyProcs', 'copyConf']) it works as expected.

Not sure what the reason it.

tmarshall avatar Apr 24 '18 03:04 tmarshall

^ full taskfile content (with serial fix) here: https://github.com/ConjureLabs/hob/blob/master/taskfile.js

tmarshall avatar Apr 24 '18 03:04 tmarshall

Hi, i guess it is known issue, this is because when you run run tasks in parallel they started at the same time and share same internal context. That's why some internal vars polluted. Simple fix will be just to use serial in copyDirs task.

hzlmn avatar Apr 24 '18 09:04 hzlmn

@hzlmn did that, but seems non-intuitive. Can't scope context per job?

tmarshall avatar Apr 24 '18 17:04 tmarshall