lukeed / taskr

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

Eager glob expansion #178

Closed Akkuma closed 8 years ago

Akkuma commented 8 years ago

Currently the code calls expand aka globby each time unwrap is called. It seems like it would be beneficial to eagerly evaluate in source, so it is done once for each source, rather than multiple times per wrap/target.

lukeed commented 8 years ago

Yeah definitely, been thinking about this too. Would need a getter method that asks for a saved "stash", before unwrapping.

Probably live at this._.files

Akkuma commented 8 years ago

I don't think you need a getter method. I think all you need is this:

Fly.prototype.source = function (globs) {
  globs = arrify(globs);
  var flattenedGlobs = flatten(globs);

  assign(this, {
    _: {
      filters: [],
      globs: flattenedGlobs,
      files: Promise.all(flattenedGlobs.map(expand))
    }
  });

  this._.cat = undefined
  _('source %o', this._.globs)
  return this
}

in unwrap you now use roughly

Fly.prototype.unwrap = function (onResolved, onRejected) {
    this._.files.then(onResolved).catch(onRejected);
}
lukeed commented 8 years ago

Yeah, true -- by the time any filter/plugin is called, source() has already been run... early morning haze 😴

lukeed commented 8 years ago

Closed by #189