Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

minitask

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minitask - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

.npmignore

5

index.js
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",

50

readme.md

@@ -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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc