-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gulpfile.js
executable file
·120 lines (100 loc) · 3.1 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
var gulp = require('gulp');
var prompt = require('gulp-prompt');
var browserSync = require('browser-sync');
var taskConfigObj ={};
var projectname = '';
var angularappname = '';
var mainstateName = '';
var mainControllerName = '';
var statesCount = '';
var statesName = '';
projectname = 'projectX'
var handleError = function (err) {
console.log(err.name, ' in ', err.plugin, ': ', err.message);
console.log(err.getStack());
process.exit(1);
};
// gulp
gulp.task('default', function () {
gulp.src('source')
.pipe(prompt.prompt([{
type: 'input',
name: 'first',
message: 'Which project would you want to run?'
}],
function(res){
console.log("You chose " + res.first);
projectname = res.first;
gulp.start('run-project');
}
));
});
//gulp release
gulp.task('release', function () {
//still need work this is just a POC
gulp.src('source')
.pipe(prompt.prompt([{
type: 'input',
name: 'first',
message: 'Which project you want to release? type ecm'
}],
function(res){
//value is in res.first and res.second
console.log("You chose " + res.first);
projectname = res.first;
taskConfigObj = {
'buildTarget' : 'release',
'forRelease' : true,
'proj' : projectname,
'handleError' : handleError
};
require('gulp-task-loader-with-params')('gulp-tasks' , taskConfigObj);
gulp.run('releaseStart');
}
));
});
gulp.task('serve', ['requireJsTask' , 'copyAssets' , 'sass', 'copyjsDev', 'copyjsVendor', 'copyHtml','copyJson'], function () {
gulp.run('browser-sync');
gulp.watch([
'source/'+taskConfigObj.proj+'/_global-resources/sass/**/*.scss'
],
['sass']);
gulp.watch([
'source/'+taskConfigObj.proj+'/_global-resources/assets/**/*'
],['copyAssets','bs-reload']);
gulp.watch([
'source/'+taskConfigObj.proj+'/**/*.json' ,
'!source/'+taskConfigObj.proj+'/_global-resources/vendor/**/*.json'
],['copyJson', 'bs-reload']);
gulp.watch([
'source/'+taskConfigObj.proj+'/**/*.js',
'!source/'+taskConfigObj.proj+'/**/*.r.js',
'!source/'+taskConfigObj.proj+'/*.js',
'!source/'+taskConfigObj.proj+'/_global-resources/vendor/**/*.js'
],['copyjsDev', 'bs-reload']);
gulp.watch([
'source/'+taskConfigObj.proj+'/config-require.js'
],['copyConfig','requireJsTask', 'bs-reload']);
gulp.watch([
'source/'+taskConfigObj.proj+'/*.js' ,
'source/'+taskConfigObj.proj+'/**/*.r.js'
],['requireJsTask', 'bs-reload']);
gulp.watch([
'source/index.html',
'source/'+taskConfigObj.proj+'/**/*.html',
'!source/'+taskConfigObj.proj+'/_global-resources/vendor/**/*.html'
],['copyHtml', 'bs-reload']);
});
gulp.task('releaseStart', ['copyAssets' , 'sass', 'requireJsTask', 'copyjsDev', 'copyjsVendor', 'copyHtml','copyJson'], function () {
//releasing here
});
gulp.task('run-project', function () {
taskConfigObj = {
'buildTarget' : 'build',
'forRelease' : false,
'proj' : projectname,
'handleError' : handleError
};
require('gulp-task-loader-with-params')('gulp-tasks' , taskConfigObj);
gulp.run('serve');
});