Comparing version 0.0.0 to 0.0.1
module.exports = { | ||
list: require('./list.js'), | ||
runner: require('./runner.js') | ||
list: require('./lib/list.js'), | ||
runner: require('./lib/runner.js'), | ||
cache: require('./lib/cache.js') | ||
}; |
{ | ||
"name": "minitask", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "A standard/convention for running tasks over a list of files based around Node core streams2", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "node test/cache.test.js" | ||
}, | ||
"peerDependencies": { | ||
"minilog": "2.x" | ||
}, | ||
"devDependencies": { | ||
"minilog": "2.x" | ||
}, | ||
"repository": { | ||
@@ -10,0 +16,0 @@ "type": "git", |
@@ -63,4 +63,12 @@ # minitask | ||
File tasks are the other type of task. They use the Node 0.10.x stream interface based on a convention that makes using child_process.spawn particularly easy: | ||
File tasks are the other type of task. | ||
There are three different alternatives, corresponding to different native APIs: | ||
- streams: returning an object with { stdout: ..., stdin: ... } | ||
- async calls: returning a function of arity 2: function(onEach, onDone) {} | ||
They use the Node 0.10.x stream interface based on a convention that makes using child_process.spawn particularly easy: | ||
````javascript | ||
@@ -161,4 +169,42 @@ // uglify-task: runs uglify | ||
TODO: document the runner and list | ||
TODO: document the list | ||
TODO: specify how the list should be annotated with tasks | ||
### Runner API | ||
The runner is a helper method that takes an input stream (e.g. an object { stdout: ... }), an array of tasks and a done function. It instantiates tasks if necessary, and pipes the tasks together, and ensures that the last task in the pipeline calls the done function. | ||
Usage example: | ||
var runner = require('minitask').runner, | ||
tasks = [ fileTask, ... ]; | ||
var last = runner({ stdout: fs.createReadStream(filename) }, tasks, function() { | ||
console.log('done'); | ||
}); | ||
// need to do this here so we can catch the second-to-last stream's "end" event; | ||
last.stdout.pipe(process.stdout, { end: false }); | ||
## Caching | ||
File processing tasks such as package builds and metadata reads are often run multiple times. It is useful to cache the output from these tasks and only re-run the processing when a file has changed. GNU Make, for example, relies on dependency resolution + file last modified timestamps to skip work where possible. | ||
A cacheable task is any task that reads a specific file path and writes to a writable stream at the end. | ||
The caching system can either use a md5 hash, or the last modified+file size information to determine whether a task needs to be re-run. Additionally, an options hash can be passed to take into account different additional options. | ||
When the caching system is used, the task output is additionally written to a separate file. The assumption here is that each file task (with a task options hash and input md5) performs the same deterministic transformation. When the current input file's md5 and task options hash match, then the previously written cached result is streamed directly rather than running the full stack of transformations. | ||
### Cache API | ||
The cache API looks a lot like the runner API, but it requires an explicit file path and options hash. | ||
var last = cache({ filepath: filepath, cachepath: ..., md5: ..., stat: ..., options: ... }, tasks, function() { | ||
}); | ||
## Command line tool | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
18885
10
273
2
209
1
1
4
2