Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

Commit 2cd8819

Browse files
committed
added gulp support closes #29
1 parent a024635 commit 2cd8819

File tree

15 files changed

+127
-29
lines changed

15 files changed

+127
-29
lines changed

app/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ ExpressGenerator.prototype.promptDatabase = function () {
8686
};
8787

8888
ExpressGenerator.prototype.promptBuildTool = function () {
89+
90+
if (this.options.buildTool) {
91+
return true;
92+
}
93+
8994
var done = this.async();
9095
var prompt = [{
9196
type: 'list',
@@ -106,7 +111,7 @@ ExpressGenerator.prototype.promptBuildTool = function () {
106111
ExpressGenerator.prototype.buildEnv = function buildEnv() {
107112
this.sourceRoot(path.join(__dirname, 'templates', 'common'));
108113
this.expandFiles('**', { cwd: this.sourceRoot() }).map(function (file) {
109-
this.template(file, file.replace(/^_/, ''));
114+
this.template(file, file.replace(/^_/, ''));
110115
}, this);
111116

112117
var name = this.options.mvc ? 'mvc' : 'basic';
@@ -128,6 +133,8 @@ ExpressGenerator.prototype.buildEnv = function buildEnv() {
128133
if (this.options.database === 'mysql' || this.options.database === 'postgresql') {
129134
this.copy(path.join(__dirname, 'templates', 'extras', name, 'model-index.' + filetype), 'app/models/index.' + filetype);
130135
}
136+
var buildFile = this.options.buildTool === 'grunt' ? 'Gruntfile.js' : 'gulpfile.js';
137+
this.copy(path.join(__dirname, 'templates', 'extras', name, buildFile), buildFile);
131138
};
132139

133140
ExpressGenerator.prototype.assetsDirs = function assetsDirs() {

app/templates/basic-coffee/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616
"jade": "~1.3.1"<% } %><% if(options.viewEngine == 'ejs'){ %>,
1717
"ejs": "~1.0.0"<% } %>
1818
},
19-
"devDependencies": {
19+
"devDependencies": {<% if(options.buildTool == 'grunt'){ %>
2020
"grunt": "~0.4.5",
2121
"grunt-develop": "~0.4.0",
2222
"grunt-contrib-watch": "~0.6.1",
2323
"request": "~2.36.0",
2424
"time-grunt": "~0.3.2",
2525
"load-grunt-tasks": "~0.6.0",
26-
"coffee-script": "^1.7.1"
26+
"coffee-script": "^1.7.1"<% } %><% if(options.buildTool == 'gulp'){ %>
27+
"gulp": "~3.8.8",
28+
"gulp-nodemon": "~1.0.4",
29+
"gulp-livereload": "~2.1.1"<% } %>
2730
}
2831
}

app/templates/basic/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
"jade": "~1.3.1"<% } %><% if(options.viewEngine == 'ejs'){ %>,
1616
"ejs": "~1.0.0"<% } %>
1717
},
18-
"devDependencies": {
18+
"devDependencies": {<% if(options.buildTool == 'grunt'){ %>
1919
"grunt": "~0.4.5",
2020
"grunt-develop": "~0.4.0",
2121
"grunt-contrib-watch": "~0.6.1",
2222
"request": "~2.36.0",
2323
"time-grunt": "~0.3.2",
24-
"load-grunt-tasks": "~0.6.0"
24+
"load-grunt-tasks": "~0.6.0"<% } %><% if(options.buildTool == 'gulp'){ %>
25+
"gulp": "~3.8.8",
26+
"gulp-nodemon": "~1.0.4",
27+
"gulp-livereload": "~2.1.1"<% } %>
2528
}
2629
}
File renamed without changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var gulp = require('gulp'),
2+
nodemon = require('gulp-nodemon'),
3+
livereload = require('gulp-livereload');
4+
5+
gulp.task('develop', function () {
6+
livereload.listen();
7+
nodemon({
8+
script: 'bin/www',
9+
ext: 'js coffee <%= options.viewEngine %>',
10+
}).on('restart', function () {
11+
setTimeout(function () {
12+
livereload.changed();
13+
}, 500);
14+
});
15+
});
16+
17+
gulp.task('default', ['develop']);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var gulp = require('gulp'),
2+
nodemon = require('gulp-nodemon'),
3+
livereload = require('gulp-livereload');
4+
5+
gulp.task('develop', function () {
6+
livereload.listen();
7+
nodemon({
8+
script: 'bin/www',
9+
ext: 'js <%= options.viewEngine %>',
10+
}).on('restart', function () {
11+
setTimeout(function () {
12+
livereload.changed();
13+
}, 500);
14+
});
15+
});
16+
17+
gulp.task('default', ['develop']);
File renamed without changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var gulp = require('gulp'),
2+
nodemon = require('gulp-nodemon'),
3+
livereload = require('gulp-livereload');
4+
5+
gulp.task('develop', function () {
6+
livereload.listen();
7+
nodemon({
8+
script: 'app.js',
9+
ext: 'js coffee <%= options.viewEngine %>',
10+
}).on('restart', function () {
11+
setTimeout(function () {
12+
livereload.changed();
13+
}, 500);
14+
});
15+
});
16+
17+
gulp.task('default', ['develop']);

0 commit comments

Comments
 (0)