1
Fork 0

change origin argument in .use into an object to support forthcoming additional arguments

This commit is contained in:
Conduitry 2017-05-09 12:03:40 -04:00
parent b992d8c697
commit 953f1efda4
2 changed files with 8 additions and 8 deletions

4
API.md
View file

@ -103,12 +103,12 @@ Starts the Defiler running. No additional configuration (registering Gazes, tran
## Operation
### `use(path, origin)`
### `use(path, { from })`
Waits for a file or array of files to be ready.
- `path` - The path or paths to wait for to become available.
- `origin` - (optional) A path of a file to re-process if any of the file or files given in `path` change. (Typically, this is the path to the file you are currently transforming or generating.)
- `from` - (optional) A path of a file to re-process if any of the file or files given in `path` change. (Typically, this is the path to the file you are currently transforming or generating.)
Returns a promise resolving to the `File` instance or an array of `File` instances.

View file

@ -148,16 +148,16 @@ export default class Defiler extends EventEmitter {
// post-exec methods
async use(path, origin) {
async use(path, { from } = {}) {
this._checkAfterExec('use')
if (Array.isArray(path)) {
return Promise.all(path.map(path => this.use(path, origin)))
return Promise.all(path.map(path => this.use(path, { from })))
}
if (origin) {
if (this._dependencies.has(origin)) {
this._dependencies.get(origin).add(path)
if (from) {
if (this._dependencies.has(from)) {
this._dependencies.get(from).add(path)
} else {
this._dependencies.set(origin, new Set([path]))
this._dependencies.set(from, new Set([path]))
}
}
if (this._filePromises) {