genome
Simple build system using ES6 classes, generators, and promises
Installation
genome requires io.js or node.js with harmony flags.
npm i -g genome
npm i -save-dev genome
Usage
Create a genomefile.js
in your project's root directory.
var genome = ; genometasks = // Tasks go here; // Run tasks passed in from command linegenome;
Create tasks
Tasks in genome are generator functions. Task names may include colons (:) and/or hyphens (-).
* { console;} * 'say-something-else' console; * 'say:goodbye' console;
Run tasks
In your command line, run:
genome sayhi
genome commands may accept multiple tasks to run asyncronously:
genome sayhi say-something-else say:goodbye
Run a task from within another task using genome.spawn()
.
* { genome; // Or use genome's shorthand methods: genome;}
genome.spawn()
accepts strings and arrays. Arrays of tasks will be run asyncronously.
* { genome;} // Is the same as: * { genome; genome; genome;}
If you need tasks to run in a certain order, add the yield statement before calling genome.spawn()
.
* { genome; genome; genome;}
Read/write files
Genome adds read()
and write()
methods to strings to make reading and writing files as easy as:
return 'dist/html.index';
Genome also adds a .contents
property as a read/write shorthand, so the same code can be written as:
'dist/html.index'contents = 'app/html.index'contents;
Not that read()
, write()
and the .contents
getter all return promises, but the .contents
setter
does not return anything. So if you need the file to be written before something else happens, use write()
.
.write()
accepts strings, promises, streams and arrays of file objects.
Processing files
Genome does not require plugins like gulp or grunt. Simply install standard node packages and use their build-in api.
* { // Process one file and output it var slm = ; return 'dist/index.html';} * { // Output stream to file var browserify = ; return 'dist/scripts/app.js';} * { // Output multiple files to directory with the String.prototype.use method var stylus = ; return 'dist/styles/';}
Watch files
Watch files for changes with String.prototype.onChange, passing in a function or a task name or array of task names.
* { 'app/**/*.slm'; 'app/scripts/**/*.js'; 'app/styles/**/*.styl'; 'dist/**/*';}
Project Goals
- Never require speciallized plugins like Gulp and Grunt
- Keep code as simple and natural as possible