/
taskr.d.ts
132 lines (109 loc) · 3.07 KB
/
taskr.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
declare namespace taskr {
export interface Instance {
/**
* Start a Task by its name; may also pass initial values.
* Can return anything the Task is designed to.
*/
start(task: string, options?: object),
/**
* Run a group of tasks simultaneously. Cascading is disabled
*/
parallel(tasks: Array<string>, options?: object): IterableIterator<any>,
/**
* Run a group of tasks sequentially. Cascading is enabled
*/
serial(tasks: Array<string>, options?: object): IterableIterator<any>
/**
* Perform local plugin
*/
plugin(name: string, options: any, plugin?: (files: any, options?: any) => Iterator<any>)
}
export interface Utils {
/**
* Print to console with timestamp and alert coloring
*/
alert(...msg: Array<string>): void,
/**
* Alias for `Bluebird.coroutine`.
*/
coroutine(generator: GeneratorFunction),
/**
* Print to console with timestamp and error coloring.
*/
error(...msg: Array<string>): void,
/**
* Get all filepaths that match the glob pattern constraints.
*/
expand(globs: string | Array<string>, options?: object)
/**
* Find a complete filepath from a given path, or optional directory.
*/
find(filename: string, dir: string)
/**
* Print to console with timestamp and normal coloring.
*/
log(...msg: Array<string>): void
/**
* Alias for `Bluebird.promisify`.
*/
promisify(fn: Function): Function
/**
* Get a file's contents. Ignores directory paths.
*/
read(filepath: string, options?: object | string): IterableIterator<string |null | BufferSource>
/**
* Parse and prettify an Error's stack.
*/
trace(stack: string): string
/**
* Write given data to a filepath. Will create directories as needed.
*/
write(filepath: string, data: any , options?: object)
}
interface File {
dir: string,
base: string,
data: any
}
type InnerState = {
/**
* The Task's active files.
* Each object contains a dir and base key from its pathObject and
* maintains the file's Buffer contents as a data key.
*/
files: Array<File>
/**
* The Task's glob patterns, from task.source(). Used to populate `task._.files`.
*/
globs: Array<string>
/**
* The Task's last-known (aka, outdated) set of glob patterns. Used only for `taskr-watch`.
*/
prevs: Array<string>
}
export interface Task extends Instance {
/**
* The directory wherein taskfile.js resides,
* now considered the root. Also accessible within plugins
*/
root: string
/**
* The Task's internal state, populated by task.source().
* Also accessible within plugins.
*/
_: InnerState
/**
* A collection of utility helpers to make life easy.
*/
$: Utils
source(globs: Array<string> | string, options?: object)
/**
* Send output to certain destination(s)
*/
target(dirs: Array<string> | string, options?: object)
/**
* Perform an inline plugin.
*/
run(options: any, plugin?: (files: any, options?: any) => Iterator<any>)
}
}