mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
gulp & orchestrator type fixes (gulp extends orchestartor)
This commit is contained in:
@@ -27,6 +27,9 @@ gulp.task('test', ['compile', 'compile2'], function()
|
||||
|
||||
gulp.task('default', ['compile', 'test']);
|
||||
|
||||
gulp.task('another', ['with1', 'with2'])
|
||||
.task('some', ['other1', 'other2'], function(cb) { cb(null); })
|
||||
.task('last', function() { });
|
||||
|
||||
|
||||
var opts = {};
|
||||
|
||||
Vendored
+14
-1
@@ -14,6 +14,7 @@ declare type Strings = string|string[];
|
||||
|
||||
declare namespace gulp {
|
||||
interface Gulp extends Orchestrator {
|
||||
task(name: string): never;
|
||||
/**
|
||||
* Define a task
|
||||
* @param name The name of the task.
|
||||
@@ -24,7 +25,19 @@ declare namespace gulp {
|
||||
* <li>Return a stream or a promise</li>
|
||||
* </ul>
|
||||
*/
|
||||
task: Orchestrator.AddMethod;
|
||||
task(name: string, fn?: Orchestrator.TaskFunc): Gulp;
|
||||
/**
|
||||
* Define a task
|
||||
* @param name The name of the task.
|
||||
* @param deps An array of task names to be executed and completed before your task will run.
|
||||
* @param fn The function that performs the task's operations. For asynchronous tasks, you need to provide a hint when the task is complete:
|
||||
* <ul>
|
||||
* <li>Take in a callback</li>
|
||||
* <li>Return a stream or a promise</li>
|
||||
* </ul>
|
||||
*/
|
||||
task(name: string, deps?: string[], fn?: Orchestrator.TaskFunc): Gulp;
|
||||
|
||||
/**
|
||||
* Takes a number of task names or functions and returns a function of the composed tasks or functions
|
||||
* When the returned function is executed, the tasks or functions will be executed in series,
|
||||
|
||||
Vendored
+15
-9
@@ -11,7 +11,7 @@ import * as Q from "q";
|
||||
|
||||
type _Sequencify = (tasks: Array<{ dep: string[]; }>, names: string[]) => { sequence: string[]; missingTasks: string[]; recursiveDependencies: string[]; };
|
||||
|
||||
type _runTask = (task: Orchestrator.TaskMethod, done: (err: any, meta: Orchestrator.Meta) => void) => void;
|
||||
type _runTask = (task: Orchestrator.TaskFunc, done: (err: any, meta: Orchestrator.Meta) => void) => void;
|
||||
|
||||
type Strings = string|string[];
|
||||
|
||||
@@ -25,6 +25,13 @@ declare class Orchestrator extends events.EventEmitter {
|
||||
|
||||
reset(): Orchestrator;
|
||||
|
||||
/** Define a task
|
||||
* @param name The name of the task.
|
||||
* @param fn The function that performs the task's operations. For asynchronous tasks, you need to provide a hint when the task is complete:
|
||||
* - Take in a callback
|
||||
* - Return a stream or a promise
|
||||
*/
|
||||
add(name: string, fn?: Orchestrator.TaskFunc): Orchestrator;
|
||||
/** Define a task
|
||||
* @param name The name of the task.
|
||||
* @param deps An array of task names to be executed and completed before your task will run.
|
||||
@@ -32,12 +39,11 @@ declare class Orchestrator extends events.EventEmitter {
|
||||
* - Take in a callback
|
||||
* - Return a stream or a promise
|
||||
*/
|
||||
add: Orchestrator.AddMethod;
|
||||
add(name: string, deps?: string[], fn?: Orchestrator.TaskFunc): Orchestrator;
|
||||
|
||||
task(name: string): Orchestrator.Task;
|
||||
task(name: string, fn: Orchestrator.TaskMethod): void;
|
||||
task(name: string, dep: string[], fn: Orchestrator.TaskMethod): void;
|
||||
task(name: string, dep?: string[] | Orchestrator.TaskMethod, fn?: Orchestrator.TaskMethod): void;
|
||||
task(name: string, fn: Orchestrator.TaskFunc): void;
|
||||
task(name: string, dep: string[], fn: Orchestrator.TaskFunc): void;
|
||||
|
||||
/** Have you defined a task with this name?
|
||||
* @param name The task name to query
|
||||
@@ -96,7 +102,7 @@ declare namespace Orchestrator {
|
||||
|
||||
/** A task, can either call a callback to indicate task completion or return a promise or a stream: (task is marked complete when promise.then() resolves/fails or stream ends)
|
||||
*/
|
||||
type TaskMethod = (callback: (err?: any) => void) => Q.Promise<any> | stream.Stream | any;
|
||||
type TaskFunc = (callback: (err?: any) => void) => Q.Promise<any> | stream.Stream | any;
|
||||
|
||||
interface AddMethod {
|
||||
/** Define a task
|
||||
@@ -105,7 +111,7 @@ declare namespace Orchestrator {
|
||||
* - Take in a callback
|
||||
* - Return a stream or a promise
|
||||
*/
|
||||
(name: string, fn?: TaskMethod): Orchestrator;
|
||||
(name: string, fn?: TaskFunc): Orchestrator;
|
||||
/** Define a task
|
||||
* @param name The name of the task.
|
||||
* @param deps An array of task names to be executed and completed before your task will run.
|
||||
@@ -113,7 +119,7 @@ declare namespace Orchestrator {
|
||||
* - Take in a callback
|
||||
* - Return a stream or a promise
|
||||
*/
|
||||
(name: string, deps?: string[], fn?: TaskMethod): Orchestrator;
|
||||
(name: string, deps?: string[], fn?: TaskFunc): Orchestrator;
|
||||
}
|
||||
|
||||
/** Start running the tasks
|
||||
@@ -149,7 +155,7 @@ declare namespace Orchestrator {
|
||||
}
|
||||
|
||||
interface Task {
|
||||
fn: TaskMethod;
|
||||
fn: TaskFunc;
|
||||
dep: string[];
|
||||
name: string;
|
||||
done?: boolean;
|
||||
|
||||
@@ -43,6 +43,20 @@ orchestrator.add('thing4', function(){
|
||||
return stm;
|
||||
});
|
||||
|
||||
//
|
||||
// orchestrator.task(name[, deps][, function]);
|
||||
//
|
||||
|
||||
orchestrator.task('task1');
|
||||
|
||||
orchestrator.task('task2', function(cb) {
|
||||
cb(null);
|
||||
});
|
||||
|
||||
orchestrator.task('task3', ['task1', 'task2'], function() {
|
||||
// do stuff
|
||||
});
|
||||
|
||||
//
|
||||
// orchestrator.hasTask(name);
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user