development-tool
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -47,4 +47,5 @@ /// <reference types="gulp" /> | ||
getRootPath(): string; | ||
allTasks(): void[]; | ||
start(): Src; | ||
protected printHelp(help: string): void; | ||
} |
@@ -90,2 +90,7 @@ "use strict"; | ||
// } | ||
Development.prototype.allTasks = function () { | ||
return this.map(function (t) { | ||
t.getRunSequence(); | ||
}); | ||
}; | ||
Development.prototype.start = function () { | ||
@@ -95,13 +100,29 @@ var _this = this; | ||
var isRoot = !this.parent; | ||
var btsk = isRoot ? 'build' : "build-" + this.taskName(this.toStr(this.option.name)); | ||
var btsk = isRoot ? 'build' : "build-" + this.taskName(this.option.name); | ||
gulp.task(btsk, function (callback) { | ||
return _this.run(); | ||
}); | ||
gulp.task(isRoot ? 'start' : "start-" + this.taskName(this.toStr(this.option.name)), function (callback) { | ||
if (!_this.env.task) { | ||
return Promise.reject('start task can not empty!'); | ||
gulp.task(isRoot ? 'start' : "start-" + this.taskName(this.option.name), function (callback) { | ||
var tasks = _this.env.task ? _this.env.task.split(',') : []; | ||
var contextname = _this.env['context']; | ||
var runCtx = contextname ? _this.find(function (ctx) { return ctx.toStr(ctx.option.name) === contextname; }) : _this; | ||
if (tasks && tasks.length > 0) { | ||
return runCtx.setup() | ||
.then(function () { | ||
var excTasks = []; | ||
tasks.forEach(function (tk) { | ||
runCtx.each(function (c) { | ||
_.each(_.flatten(c.getRunSequence()), function (t) { | ||
if (t.endsWith(tk) && excTasks.indexOf(t) < 0) { | ||
excTasks.push(t); | ||
} | ||
}); | ||
}); | ||
}); | ||
_this.runSequence(excTasks); | ||
}); | ||
} | ||
var tasks = _this.env.task.split(','); | ||
return _this.find(function (ctx) { return tasks.indexOf(ctx.toStr(ctx.option.name)) >= 0; }) | ||
.run(); | ||
else { | ||
return runCtx.run(); | ||
} | ||
}); | ||
@@ -108,0 +129,0 @@ if (!this.parent) { |
{ | ||
"name": "development-tool", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "development tools, tasks component, gulp task manager, tasks loader, run tasks in sequence via Promise. easy to load tasks module, generate asserts task, compose tasks.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/tools.js", |
@@ -95,6 +95,12 @@ import * as _ from 'lodash'; | ||
allTasks() { | ||
return this.map((t) => { | ||
t.getRunSequence(); | ||
}) | ||
} | ||
start(): Src { | ||
let gulp = this.gulp; | ||
let isRoot = !this.parent; | ||
let btsk = isRoot ? 'build' : `build-${this.taskName(this.toStr(this.option.name))}`; | ||
let btsk = isRoot ? 'build' : `build-${this.taskName(this.option.name)}`; | ||
gulp.task(btsk, (callback: TaskCallback) => { | ||
@@ -104,9 +110,25 @@ return this.run(); | ||
gulp.task(isRoot ? 'start' : `start-${this.taskName(this.toStr(this.option.name))}`, (callback: TaskCallback) => { | ||
if (!this.env.task) { | ||
return Promise.reject('start task can not empty!'); | ||
gulp.task(isRoot ? 'start' : `start-${this.taskName(this.option.name)}`, (callback: TaskCallback) => { | ||
let tasks = this.env.task ? this.env.task.split(',') : []; | ||
let contextname: string = this.env['context']; | ||
let runCtx = contextname ? this.find<Context>(ctx => ctx.toStr(ctx.option.name) === contextname) : this; | ||
if (tasks && tasks.length > 0) { | ||
return runCtx.setup() | ||
.then(() => { | ||
let excTasks = []; | ||
tasks.forEach(tk => { | ||
runCtx.each(c => { | ||
_.each(_.flatten(c.getRunSequence()), t => { | ||
if (t.endsWith(tk) && excTasks.indexOf(t) < 0) { | ||
excTasks.push(t) | ||
} | ||
}); | ||
}) | ||
}); | ||
this.runSequence(excTasks); | ||
}); | ||
} else { | ||
return runCtx.run(); | ||
} | ||
let tasks = this.env.task.split(','); | ||
return this.find<Context>(ctx => tasks.indexOf(ctx.toStr(ctx.option.name)) >= 0) | ||
.run(); | ||
}); | ||
@@ -113,0 +135,0 @@ |
Sorry, the diff of this file is not supported yet
190146
2965