-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·102 lines (77 loc) · 2.41 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
95
96
97
98
99
//core
const gulp = require('gulp');
const path = require('path');
const fs = require('fs');
const async = require('async');
const _ = require('underscore');
const request = require('request');
const ijson = require('siamese');
const cp = require('child_process');
//gulp plugins
const babel = require('gulp-babel');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const rename = require('gulp-rename');
const nodemon = require('gulp-nodemon');
const requirejs = require('gulp-requirejs');
//suman utils
const defaultConfig = require('./suman.conf');
//args & env
const argv = JSON.parse(JSON.stringify(process.argv));
const $node_env = process.env.NODE_ENV;
//you should be able to run your tests with gulp, instead of npm run blah
gulp.task('clean-temp', function () {
return del(['dest']);
});
gulp.task('transpile-lib', [/*'clean-temp'*/], function () {
return gulp.src(['server/lib-es6/**/*.js'])
.pipe(babel({
presets: ['react']
}))
.pipe(gulp.dest('server/lib-es5'));
});
gulp.task('transpile-rc', ['transpile-lib'], function () {
return gulp.src(['server/lib-es5/react-components/**/*.js'])
.pipe(babel({
plugins: ['transform-es2015-modules-amd']
}))
.pipe(gulp.dest('server/public/js/react-components'));
});
gulp.task('convert', ['transpile-lib'], function (cb) { //convert commonjs to amd
cp.exec('node_modules/.bin/r.js -convert server/lib-es5/react-components server/public/js/react-components', function (err, stdout, stderr) {
if (err) {
cb(err)
}
else if (err = (String(stdout).match(/error/i) || String(stderr).match(/error/i))) {
console.error(stdout + stderr);
cb(err);
}
else {
cb(null);
}
});
});
gulp.task('collect-coverage', [], function (cb) {
cp.exec('istanbul cover test/build-tests/test6.js test/build-tests/test7.js', function (err, stdout, stderr) {
if (err) {
console.error(err.stack);
}
console.log(stdout);
console.log(stderr);
cb(null);
});
});
gulp.task('nodemon', ['convert'], function () {
nodemon({
script: 'server/bin/www',
ext: 'js',
ignore: ['server/lib-es5/**/*', 'server/public/*', '*.git/*', '*.idea/*', 'gulpfile.js'],
args: [], //TODO: add these from command line
nodeArgs: ['--harmony'],
env: Object.assign({}, process.env, {
NODE_ENV: $node_env || 'development',
SUMAN_CONFIG: JSON.stringify(defaultConfig),
SUMAN_SERVER_OPTS: ''
})
}).on('restart', ['convert']);
});