-
Notifications
You must be signed in to change notification settings - Fork 60
/
gulpfile.js
78 lines (70 loc) · 2.26 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
/**
* Created by nantas on 15/2/11.
*/
var gulp = require('gulp');
var gutil = require('gulp-util');
var exec = require('child_process').exec;
var del = require('del');
var shellVersion = require('./package.json')['fire-shell-version'];
var nativeModules = require('./package.json')['native-modules'];
console.log(shellVersion);
console.log(nativeModules);
gulp.task('install-downloader', function(cb) {
try {
if (require('gulp-download-fire-shell')) {
cb();
}
} catch(e) {
var child = exec('npm install gulp-download-fire-shell');
child.stdout.on('data', function(data) {
gutil.log(data.toString());
});
child.stderr.on('data', function(data) {
gutil.log(data.toString());
});
child.on('exit', function() {
gutil.log('Fire-shell downloader installed successfully! \n Please run "gulp get" to download fire-shell binary and native modules.');
cb();
});
}
});
gulp.task('get-fire-shell', ['install-downloader'], function(cb) {
var updateFireShell = require('gulp-download-fire-shell');
updateFireShell.downloadFireShell({
version: shellVersion,
outputDir: 'fire-shell',
chinaMirror: true
}, cb);
});
gulp.task('remove-native-modules', function(cb) {
var modulePaths = nativeModules.map(function(name) {
return 'node_modules/' + name;
});
del(modulePaths, cb);
});
gulp.task('get-native-module', ['install-downloader'], function(cb) {
var updateFireShell = require('gulp-download-fire-shell');
updateFireShell.downloadNativeModules({
version: shellVersion,
outputDir: 'node_modules',
nativeModules: nativeModules,
isFireShell: true,
chinaMirror: true
}, cb);
});
gulp.task('get', ['get-fire-shell', 'get-native-module']);
gulp.task('run', function() {
var cmd;
if (process.platform === "win32") {
cmd = 'call fire-shell\\fireball.exe %cd%';
} else {
cmd = './fire-shell/Fireball.app/Contents/MacOS/Fireball ./ --dev';
}
var child = exec(cmd);
child.stdout.on('data', function(data) {
gutil.log(data.toString());
});
child.stderr.on('data', function(data) {
gutil.log(data.toString());
});
});