-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
62 lines (48 loc) · 1.5 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
/**
* Created by techmaster on 2/11/17.
*/
/**
* Created by techmaster on 2/5/17.
*/
const spawn = require('child_process').spawn;
const gutil = require('gulp-util');
const gulp = require('gulp');
function run_command(command, options) {
const child = spawn(command, options, {cwd: process.cwd()});
let stdout = '', stderr = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', function (data) {
stdout += data;
gutil.log(data);
});
child.stderr.setEncoding('utf8');
child.stderr.on('data', function (data) {
stderr += data;
gutil.log(gutil.colors.red(data));
gutil.beep();
});
child.on('close', function (code) {
gutil.log("Done with exit code", code);
gutil.log("You access complete stdout and stderr from here"); // stdout, stderr
});
}
gulp.task('default', ['nopromise', 'promise', 'asynawait', 'await_ajax']);
//-------- Running app using npm start
gulp.task('nopromise', () => {
run_command('node', ['nopromise.js']);
});
gulp.task('promise', () => {
run_command('node', ['promise.js']);
});
/***
* Để chạy tính năng async - await cần có option --harmony-async-await
*/
gulp.task('asynawait', () => {
//run_command('node', ['--harmony-async-await', 'asynawait.js']);
run_command('node', ['asynawait.js']);
});
gulp.task('await_ajax', () => {
//remove --harmony-async-await option if you use Node.js version 7.6.0 or later
//run_command('node', ['--harmony-async-await', 'awaitajax.js']);
run_command('node', ['awaitajax.js']);
});