lukeed / taskr

A fast, concurrency-focused task automation tool.
MIT License
2.53k stars 74 forks source link

Uncorrect output for task #232

Closed hzlmn closed 7 years ago

hzlmn commented 7 years ago
const main = 'app/ui-kit'
const dist = 'dist'

/**
 * images
 */
const images = `${main}/img/**/*`
const imagesDist = `${dist}/gl-uikit/img`

x.copyImages = function * () {
  yield this.source(images).target(imagesDist)
}

it works fine, but with

const main = './app/ui-kit'
const dist = './dist'

output is not produced as expected

lukeed commented 7 years ago

In my mind, that's okay lol. Imo no one should ever be using ./ to precede their paths. It's totally redundant.

But I suppose I can/should allow it, despite my personal opinions 😆

hzlmn commented 7 years ago

@lukeed It's fine, but how I can specify path like ../dist without adding path?

lukeed commented 7 years ago

If this is your app structure:

|- \project
  |- \app
    |- flyfile.js
  |- \dist

And you want to send files to dist, then using ../dist will work just fine.

If, however, this is your structure:

|- \project
  |- flyfile.js
  |- \app
  |- \dist

Then all you need to specify is dist. Although, ./dist will work too. Just tried it.

hzlmn commented 7 years ago

Oh, right. it's only broken when in second structure i specify path like ./app for this.source

lukeed commented 7 years ago

What's the output when you do that?

output is not produced as expected

is too vague to work with 😎

hzlmn commented 7 years ago

my bad :smile: it's empty folder but when without ./ in the beginning, it copy files as expected.

lukeed commented 7 years ago

Hmm. Is that on Windows?

hzlmn commented 7 years ago

Nope. Linux (Ubuntu 14 LTS)

lukeed commented 7 years ago

Do me a favor?

Wrap norm(...) with a path.resolve() here?

hzlmn commented 7 years ago

same thing. btw seems like files matched correctly

[ './app/ui-kit/fonts/gl-font/glfont.eot',
  './app/ui-kit/fonts/gl-font/glfont.svg',
  './app/ui-kit/fonts/gl-font/glfont.ttf',
  './app/ui-kit/fonts/gl-font/glfont.woff',
  './app/ui-kit/fonts/gl-font/selection.json' ]

Here is output for files

lukeed commented 7 years ago

Ok, then go to target and log out trims and each o.dir final value (after the for-loop).

hzlmn commented 7 years ago
trims [ './app/ui-kit/fonts' ]
dir for glfont.eot /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font
dir for glfont.svg /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font
dir for glfont.ttf /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font
dir for glfont.woff /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font
dir for selection.json /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font

Seems like target dir equals sourcing.

And here is output without ./

trims [ 'app/ui-kit/fonts' ]
dir for glfont.eot /home/olehkuchuk/Projects/gl-uikit/./dist/gl-uikit/fonts/gl-font
dir for glfont.svg /home/olehkuchuk/Projects/gl-uikit/./dist/gl-uikit/fonts/gl-font
dir for glfont.ttf /home/olehkuchuk/Projects/gl-uikit/./dist/gl-uikit/fonts/gl-font
dir for glfont.woff /home/olehkuchuk/Projects/gl-uikit/./dist/gl-uikit/fonts/gl-font
dir for selection.json /home/olehkuchuk/Projects/gl-uikit/./dist/gl-uikit/fonts/gl-font
lukeed commented 7 years ago

So you placed console.log('dir for ', o.base, o.dir) here?

hzlmn commented 7 years ago

Mm, I got it. When you replace it here when path with ./ replacement not working

dir: /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font, trim: ./app/ui-kit/fonts, replacement: ./dist/gl-uikit/fonts
dir: /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font, trim: ./app/ui-kit/fonts, replacement: ./dist/gl-uikit/fonts
dir: /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font, trim: ./app/ui-kit/fonts, replacement: ./dist/gl-uikit/fonts
dir: /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font, trim: ./app/ui-kit/fonts, replacement: ./dist/gl-uikit/fonts
dir: /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font, trim: ./app/ui-kit/fonts, replacement: ./dist/gl-uikit/fonts
hzlmn commented 7 years ago

So you placed console.log('dir for ', o.base, o.dir) here?

yes

lukeed commented 7 years ago

Sorry, my bad. Don't replace it. This is what you should have:

for (const t of trims) {
  o.dir = o.dir.replace(t, d);
}
console.log(`dir for ${o.base}: `, o.dir);
hzlmn commented 7 years ago

Sorry, my bad. Don't replace it

What do you mean?

lukeed commented 7 years ago

Haha, does your current code look like this?

for (const t of trims) {
  o.dir = o.dir.replace(t, d);
}
console.log(`dir for ${o.base}: `, o.dir);
hzlmn commented 7 years ago

Exactly

hzlmn commented 7 years ago

What I actually mean is that when you replace o.dir here

for (const t of trims) {
  console.log(`dir: ${o.dir}, trim: ${t}, replacement: ${d}`)
  o.dir = o.dir.replace(t, d); // here is replacement is broken when path contains './'
}

Here is output of log

dir: /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font, trim: ./app/ui-kit/fonts, replacement: ./dist/gl-uikit/fonts
dir: /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font, trim: ./app/ui-kit/fonts, replacement: ./dist/gl-uikit/fonts
dir: /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font, trim: ./app/ui-kit/fonts, replacement: ./dist/gl-uikit/fonts
dir: /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font, trim: ./app/ui-kit/fonts, replacement: ./dist/gl-uikit/fonts
dir: /home/olehkuchuk/Projects/gl-uikit/app/ui-kit/fonts/gl-font, trim: ./app/ui-kit/fonts, replacement: ./dist/gl-uikit/fonts
lukeed commented 7 years ago

@hzlmn Ah. That isn't very helpful. Please try what I pasted above & send me the output.

Thanks

lukeed commented 7 years ago

Ok, fixed. Please checkout the new commit & verify that it works on your end.

Sorry for all the back 'n forth!