forked from gulpjs/gulp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.mjs
70 lines (58 loc) · 1.56 KB
/
index.mjs
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
import Undertaker from 'undertaker'
import vinylFs from 'vinyl-fs'
import watch from '@sequencemedia/glob-watcher'
function getOpts (opts = {}) {
return {
allowEmpty: true,
...opts
}
}
class Gulp extends Undertaker {
constructor () {
super()
// Bind the functions for destructuring
this.watch = this.watch.bind(this)
this.task = this.task.bind(this)
this.series = this.series.bind(this)
this.parallel = this.parallel.bind(this)
this.registry = this.registry.bind(this)
this.tree = this.tree.bind(this)
this.lastRun = this.lastRun.bind(this)
this.src = this.src.bind(this)
this.dest = this.dest.bind(this)
this.symlink = this.symlink.bind(this)
}
src (glob, opts = {}) {
return vinylFs.src(glob, getOpts(opts))
}
dest (dest, opts = {}) {
return vinylFs.dest(dest, getOpts(opts))
}
symlink (dest, opts = {}, ...rest) {
return vinylFs.symlink(dest, getOpts(opts), ...rest)
}
watch (glob, opts, task) {
if (
typeof opts === 'string' ||
typeof task === 'string' ||
Array.isArray(opts) ||
Array.isArray(task)
) {
throw new Error(`watching ${glob}: watch task has to be ` +
'a function (optionally generated by using gulp.parallel ' +
'or gulp.series)')
}
if (typeof opts === 'function') {
task = opts
opts = {}
}
opts = opts || {}
let func
if (typeof task === 'function') {
func = this.parallel(task)
}
return watch(glob, getOpts(opts), func)
}
static Gulp = Gulp
}
export default new Gulp()