forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.ts
98 lines (81 loc) · 2.02 KB
/
gulpfile.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
import gulp from 'gulp'
import { rimraf } from 'rimraf'
import { waitUntilIconsBuilt } from '../../scripts/ensure-icons'
import cp from 'child_process'
import * as path from 'path'
const nodeWebpack = path.join(__dirname, '..', '..', 'scripts', 'run-webpack.js')
async function cypressIcons () {
await waitUntilIconsBuilt()
return require('@packages/icons')
}
function clean (): Promise<boolean> {
return rimraf('dist')
}
const manifest = (v: 'v2' | 'v3') => {
return () => {
return gulp.src(`app/${v}/manifest.json`)
.pipe(gulp.dest(`dist/${v}`))
}
}
const background = (cb) => {
cp.fork(nodeWebpack, { stdio: 'inherit' }).on('exit', (code) => {
cb(code === 0 ? null : new Error(`Webpack process exited with code ${code}`))
})
}
const copyScriptsForV3 = () => {
return gulp.src('app/v3/*.js')
.pipe(gulp.dest('dist/v3'))
}
const html = () => {
return gulp.src('app/**/*.html')
.pipe(gulp.dest('dist/v2'))
.pipe(gulp.dest('dist/v3'))
}
const css = () => {
return gulp.src('app/**/*.css')
.pipe(gulp.dest('dist/v2'))
.pipe(gulp.dest('dist/v3'))
}
const icons = async () => {
const cyIcons = await cypressIcons()
return gulp.src([
cyIcons.getPathToIcon('icon_16x16.png'),
cyIcons.getPathToIcon('icon_19x19.png'),
cyIcons.getPathToIcon('icon_38x38.png'),
cyIcons.getPathToIcon('icon_48x48.png'),
cyIcons.getPathToIcon('icon_128x128.png'),
])
.pipe(gulp.dest('dist/v2/icons'))
.pipe(gulp.dest('dist/v3/icons'))
}
const logos = async () => {
const cyIcons = await cypressIcons()
// appease TS
return gulp.src([
cyIcons.getPathToLogo('cypress-bw.png'),
])
.pipe(gulp.dest('dist/v2/logos'))
.pipe(gulp.dest('dist/v3/logos'))
}
const build = gulp.series(
clean,
gulp.parallel(
icons,
logos,
manifest('v2'),
manifest('v3'),
background,
copyScriptsForV3,
html,
css,
),
)
const watchBuild = () => {
return gulp.watch('app/**/*', build)
}
const watch = gulp.series(build, watchBuild)
module.exports = {
build,
clean,
watch,
}