DefinitelyTyped/undertaker/undertaker-tests.ts
2016-02-10 00:16:03 +09:00

44 lines
1.0 KiB
TypeScript

/// <reference path="undertaker.d.ts" />
/// <reference path="../node/node.d.ts" />
var fs = require('fs');
var Undertaker = require('undertaker');
import { Registry } from 'undertaker';
var taker = new Undertaker();
taker.task('task1', function(cb: () => void){
// do things
cb(); // when everything is done
});
taker.task('task2', function(){
return fs.createReadStream('./myFile.js')
.pipe(fs.createWriteStream('./myFile.copy.js'));
});
taker.task('task3', function(){
return new Promise(function(resolve, reject){
// do things
resolve(); // when everything is done
});
});
taker.task('combined', taker.series('task1', 'task2'));
taker.task('all', taker.parallel('combined', 'task3'));
var registry: Registry;
function CommonRegistry(options: { buildDir: string }): Registry {
return registry;
}
var taker = new Undertaker(CommonRegistry({ buildDir: '/dist' }));
taker.task('build', taker.series('clean', function build(cb: () => void) {
// do things
cb();
}));