forked from balena-io/balena-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
77 lines (64 loc) · 1.97 KB
/
gulpfile.coffee
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
path = require('path')
gulp = require('gulp')
mocha = require('gulp-mocha')
gutil = require('gulp-util')
coffeelint = require('gulp-coffeelint')
coffee = require('gulp-coffee')
insert = require('gulp-insert')
runSequence = require('run-sequence')
browserify = require('browserify')
uglify = require('gulp-uglify')
source = require('vinyl-source-buffer')
packageJSON = require('./package.json')
{ loadEnv } = require('./tests/util')
OPTIONS =
config:
browserLibraryName: 'resin-sdk'
files:
coffee: [ 'lib/**/*.coffee', 'tests/**/*.coffee', 'gulpfile.coffee' ]
app: 'lib/**/*.coffee'
tests: 'tests/**/*.spec.coffee'
browserEntry: 'resin.js'
browserOutput: 'resin-browser.js'
browserMinifiedOutput: 'resin-browser.min.js'
directories:
doc: 'doc/'
build: 'build/'
gulp.task 'test', ->
loadEnv()
gulp.src(OPTIONS.files.tests, read: false)
.pipe(mocha({
reporter: 'spec',
require: ['ts-node/register'],
compilers: 'coffee:coffee-script/register',
timeout: 5 * 60 * 1000,
slow: 10 * 1000
}))
gulp.task 'build', (callback) ->
runSequence('build-node', 'build-browser', callback)
gulp.task 'build-node', ->
gulp.src(OPTIONS.files.app)
.pipe(coffee(header: true, bare: true)).on('error', gutil.log)
.pipe(gulp.dest(OPTIONS.directories.build))
gulp.task 'build-browser', ['build-node'], ->
bundle = browserify
entries: OPTIONS.files.browserEntry,
basedir: OPTIONS.directories.build
standalone: OPTIONS.config.browserLibraryName
# These modules are referenced in the code, but only get used in Node:
.exclude('fs')
.exclude('path')
.exclude('resin-settings-client')
.exclude('node-localstorage')
.exclude('rindle')
.exclude('zlib')
.exclude('progress-stream')
.bundle()
bundle
.pipe(source(OPTIONS.files.browserOutput))
.pipe(insert.prepend('// Generated by browserify\n'))
.pipe(gulp.dest(OPTIONS.directories.build))
bundle
.pipe(source(OPTIONS.files.browserMinifiedOutput))
.pipe(uglify())
.pipe(gulp.dest(OPTIONS.directories.build))