-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
94 lines (79 loc) · 2.45 KB
/
gulpfile.js
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
var gulp = require('gulp');
var mkdirp = require('mkdirp');
var rename = require('gulp-rename')
var spawn = require('child_process').spawn;
var fs = require('fs');
//
// generate hcl wrapper
//
gulp.task('generate-hcl-container', (done) => {
var docker = spawn('docker', [
'build',
'-t', 'gopher-hcl-gopherjs',
'-f', 'hcl-hil/gopherjs.Dockerfile',
'hcl-hil'], { stdio: 'inherit' });
docker.on('close', (code) => {
if (code !== 0) {
done(new Error(`docker failed with code ${code}`));
} else {
done();
}
});
});
gulp.task('generate-non-closure.js', ['generate-hcl-container'], (done) => {
var docker = spawn('docker', [
'run',
'--rm', 'gopher-hcl-gopherjs'
], { stdio: ['ignore', 'pipe', 'inherit'] });
var stream = fs.createWriteStream('out/src/hcl-hil.js', { flags: 'w+' });
docker.stdout.pipe(stream);
docker.on('close', (code) => {
if (code !== 0) {
done(new Error(`docker run gopher-hcl-gopherjs failed with code ${code}`));
} else {
done();
}
});
});
gulp.task('generate-transpiled.js', ['generate-hcl-container'], (done) => {
var docker = spawn('docker', [
'run',
'--rm', 'gopher-hcl-gopherjs'
], { stdio: ['ignore', 'pipe', 'inherit'] });
var stream = fs.createWriteStream('hcl-hil/transpiled.js', { flags: 'w+' });
docker.stdout.pipe(stream);
docker.on('close', (code) => {
if (code !== 0) {
done(new Error(`docker run gopher-hcl-gopherjs failed with code ${code}`));
} else {
done();
}
});
});
gulp.task('create-output-directory', (done) => {
mkdirp('out/src', done);
});
gulp.task('generate-closure-container', ['generate-transpiled.js'], (done) => {
var docker = spawn('docker', [
'build',
'-t', 'gopher-hcl-closure-compiler',
'-f', 'hcl-hil/closure.Dockerfile',
'hcl-hil'], { stdio: 'inherit' });
docker.on('close', (code) => {
if (code !== 0) {
done(new Error(`docker failed with code ${code}`));
} else {
done();
}
});
});
gulp.task('generate-hcl-hil.js', ['create-output-directory', 'generate-transpiled.js'], (done) => {
gulp.src('hcl-hil/transpiled.js')
.pipe(rename('hcl-hil.js'))
.pipe(gulp.dest('out/src'))
done();
});
//
// default
//
gulp.task('default', ['generate-hcl-hil.js']);