-
Notifications
You must be signed in to change notification settings - Fork 51
/
gulpfile.js
71 lines (64 loc) · 2.17 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
'use strict'
const fs = require('fs')
const gulp = require('gulp')
const clean = require('gulp-clean')
const exec = require('gulp-exec')
const runSequence = require('run-sequence')
const uglify = require('gulp-uglify')
const rename = require('gulp-rename')
const pump = require('pump')
const gap = require('gulp-append-prepend')
const packagejson = require('./package.json')
gulp.task('clean', () => {
if (!fs.existsSync('./dist')) {
fs.mkdirSync('./dist')
}
return gulp.src('./dist/*', {read: false})
.pipe(clean({force: true}))
})
gulp.task('compress', cb => {
pump([
gulp.src('./dist/opentimestamps.js'),
uglify(),
gap.prependText('// ' + packagejson.name + ' v.' + packagejson.version + '\n'),
rename('opentimestamps.min.js'),
gulp.dest('./dist/')
],
cb
)
})
gulp.task('index', () => {
const options = {
continueOnError: false, // default = false, true means don't emit error event
pipeStdout: false, // default = false, true means stdout is written to file.contents
customTemplatingThing: 'test' // content passed to gutil.template()
}
const reportOptions = {
err: true, // default = true, false means don't write err
stderr: true, // default = true, false means don't write stderr
stdout: true // default = true, false means don't write stdout
}
return gulp.src('./')
.pipe(exec('./node_modules/browserify/bin/cmd.js --standalone "OpenTimestamps" index.js > ./dist/opentimestamps.es6.js', options))
.pipe(exec('./node_modules/.bin/babel ./dist/opentimestamps.es6.js -o ./dist/opentimestamps.js', options))
.pipe(exec.reporter(reportOptions))
/* NOTE: babelify run babel with .babelrc file, but doesn't convert the code
gulp.task('index', function() {
return browserify({ debug: true, entries: ["opentimestamps.es6.js"] })
.transform(babelify)
.bundle()
.pipe(source(' opentimestamps.js'))
.pipe(gulp.dest('./'));
}); */
})
gulp.task('default', gulp.series('clean', 'index', 'compress', done => {
// default task code here
done()
}));
/*
gulp.task('default', done => {
runSequence('clean', 'index', 'compress', () => {
done()
})
})
*/