Skip to content

Commit 889bd0b

Browse files
committed
add sourcemaps, jshint esnext only for es6 and fix tests
1 parent d6a55bc commit 889bd0b

File tree

16 files changed

+113
-112
lines changed

16 files changed

+113
-112
lines changed

app/files.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"staticFiles": [
33
".bowerrc",
44
".editorconfig",
5-
".jshintrc",
65

76
"gulp/e2e-tests.js",
87
"gulp/proxy.js",
@@ -16,6 +15,7 @@
1615
],
1716
"templates": [
1817
".gitignore",
18+
".jshintrc",
1919

2020
"package.json",
2121
"bower.json",

app/src/preprocessors.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ module.exports = function(GulpAngularGenerator) {
4747
}
4848

4949
this.watchTaskDeps.push('\'inject\'');
50-
51-
console.log('this.watchTaskDeps', this.watchTaskDeps);
5250
};
5351

5452
/**

app/templates/.jshintrc renamed to app/templates/_.jshintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"node": true,
3+
<% if(props.jsPreprocessor.srcExtension === 'es6') { %>
34
"esnext": true,
5+
<% } %>
46
"bitwise": true,
57
"camelcase": true,
68
"curly": true,

app/templates/gulp/_inject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var $ = require('gulp-load-plugins')();
77
var wiredep = require('wiredep').stream;
88

99
module.exports = function(options) {
10-
gulp.task('inject', function () {
10+
gulp.task('inject', ['scripts', 'styles'], function () {
1111
var injectStyles = gulp.src([
1212
<% if (props.cssPreprocessor.key !== 'none') { %>
1313
options.tmp + '/serve/{app,components}/**/*.css',

app/templates/gulp/_scripts.js

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ module.exports = function(options) {
2323
.pipe($.jshint.reporter('jshint-stylish'))
2424
<% } if (props.jsPreprocessor.key !== 'none') { %>
2525
.pipe($.sourcemaps.init())
26-
<% } if (props.jsPreprocessor.key === 'traceur') { %>
27-
.pipe($.traceur()).on('error', options.errorHandler('Traceur'))
2826
<% } if (props.jsPreprocessor.key === 'coffee') { %>
2927
.pipe($.coffeelint())
3028
.pipe($.coffeelint.reporter())
@@ -39,45 +37,50 @@ module.exports = function(options) {
3937
<% } %>
4038
<% if (props.jsPreprocessor.key === 'typescript') { %>
4139
.pipe($.toJson({filename: options.tmp + '/sortOutput.json', relative:true}))
42-
<% } %>
43-
<% if (props.jsPreprocessor.key === 'traceur') { %>
44-
.pipe(gulp.dest(options.tmp + '/traceur'))
45-
<% } else if (props.jsPreprocessor.key !== 'none') { %>
40+
<% } if (props.jsPreprocessor.key !== 'none') { %>
4641
.pipe(gulp.dest(options.tmp + '/serve/'))
4742
<% } %>
4843
.pipe(browserSync.reload({ stream: true }))
4944
.pipe($.size());
5045
});
5146
<% } else { %>
5247
function webpack(watch, callback) {
53-
return gulp.src(options.src + '/app/index.js')
54-
.pipe($.webpack({
55-
watch: watch,
56-
module: {
57-
preLoaders: [{ test: /\.js$/, exclude: /node_modules/, loader: 'jshint-loader'}],
48+
var webpackOptions = {
49+
watch: watch,
50+
module: {
51+
preLoaders: [{ test: /\.js$/, exclude: /node_modules/, loader: 'jshint-loader'}],
5852
<% if (props.jsPreprocessor.key === 'babel') { %>
59-
loaders: [{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'}]
53+
loaders: [{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'}]
6054
<% } if (props.jsPreprocessor.key === 'traceur') { %>
61-
loaders: [{ test: /\.js$/, exclude: /node_modules/, loader: 'traceur-loader'}]
55+
loaders: [{ test: /\.js$/, exclude: /node_modules/, loader: 'traceur-loader'}]
6256
<% } %>
63-
},
64-
output: { filename: 'index.js' }
65-
}, null, function(err, stats) {
66-
if(err) {
67-
options.errorHandler('Webpack')(err);
68-
}
69-
$.util.log(stats.toString({
70-
colors: $.util.colors.supportsColor,
71-
chunks: false,
72-
hash: false,
73-
version: false
74-
}));
75-
browserSync.reload();
76-
if(watch) {
77-
watch = false;
78-
callback();
79-
}
80-
}))
57+
},
58+
output: { filename: 'index.js' }
59+
};
60+
61+
if(watch) {
62+
webpackOptions.devtool = 'inline-source-map';
63+
}
64+
65+
var webpackChangeHandler = function(err, stats) {
66+
if(err) {
67+
options.errorHandler('Webpack')(err);
68+
}
69+
$.util.log(stats.toString({
70+
colors: $.util.colors.supportsColor,
71+
chunks: false,
72+
hash: false,
73+
version: false
74+
}));
75+
browserSync.reload();
76+
if(watch) {
77+
watch = false;
78+
callback();
79+
}
80+
};
81+
82+
return gulp.src(options.src + '/app/index.js')
83+
.pipe($.webpack(webpackOptions, null, webpackChangeHandler))
8184
.pipe(gulp.dest(options.tmp + '/serve/app'));
8285
}
8386

app/templates/src/app/_index.es6

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
'use strict';
2-
/*jshint esnext: true */
32

43
import MainCtrl from './main/main.controller';
54
import NavbarCtrl from '../components/navbar/navbar.controller';
65

76
angular.module('<%= appName %>', [<%= modulesDependencies %>])
87
.controller('MainCtrl', MainCtrl)
98
.controller('NavbarCtrl', NavbarCtrl)
10-
<%= routerJs %>;
9+
<%= routerJs %>;

app/templates/src/app/_index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ module <%= appName %> {
99
angular.module('<%= appName %>', [<%= modulesDependencies %>])
1010
.controller('MainCtrl', MainCtrl)
1111
.controller('NavbarCtrl', NavbarCtrl)
12-
<%= routerJs %>;
12+
<%= routerJs %>;
1313
}

app/templates/src/app/main/_main.controller.es6

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
'use strict';
2-
/*jshint esnext: true */
32

43
class MainCtrl {
54
constructor ($scope) {

app/templates/src/components/navbar/_navbar.controller.es6

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
'use strict';
2-
/*jshint esnext: true */
32

43
class NavbarCtrl {
54
constructor ($scope) {

test/node/test-preprocessors.js

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,36 +46,27 @@ describe('gulp-angular generator preprocessors script', function () {
4646
});
4747
});
4848

49-
describe('compute dependencies for the gulp inject task', function() {
50-
it('should be scripts if no preprocessors', function() {
49+
describe('compute dependencies for the gulp watch task', function() {
50+
it('should be inject if no es6 or html prepro', function() {
5151
generator.props = {
52-
cssPreprocessor: { key: 'none' },
53-
jsPreprocessor: { key: 'none' }
54-
};
55-
generator.computeInjectTaskDeps();
56-
generator.injectTaskDeps.length.should.be.equal(1);
57-
generator.injectTaskDeps[0].should.be.equal('\'scripts\'');
58-
});
59-
60-
it('should be styles and scripts when there is preprocessors', function() {
61-
generator.props = {
62-
cssPreprocessor: { key: 'not none' },
63-
jsPreprocessor: { key: 'not none' }
52+
jsPreprocessor: { srcExtension: 'notes6' },
53+
htmlPreprocessor: { key: 'none' }
6454
};
65-
generator.computeInjectTaskDeps();
66-
generator.injectTaskDeps.length.should.be.equal(2);
67-
generator.injectTaskDeps[0].should.be.equal('\'styles\'');
68-
generator.injectTaskDeps[1].should.be.equal('\'scripts\'');
55+
generator.computeWatchTaskDeps();
56+
generator.watchTaskDeps.length.should.be.equal(1);
57+
generator.watchTaskDeps[0].should.be.equal('\'inject\'');
6958
});
7059

71-
it('should be browserify for traceur', function() {
60+
it('should be inject, scripts:watch and markups when needed', function() {
7261
generator.props = {
73-
cssPreprocessor: { key: 'none' },
74-
jsPreprocessor: { key: 'traceur' }
62+
jsPreprocessor: { srcExtension: 'es6' },
63+
htmlPreprocessor: { key: 'notnone' }
7564
};
76-
generator.computeInjectTaskDeps();
77-
generator.injectTaskDeps.length.should.be.equal(1);
78-
generator.injectTaskDeps[0].should.be.equal('\'browserify\'');
65+
generator.computeWatchTaskDeps();
66+
generator.watchTaskDeps.length.should.be.equal(3);
67+
generator.watchTaskDeps[0].should.be.equal('\'scripts:watch\'');
68+
generator.watchTaskDeps[1].should.be.equal('\'markups\'');
69+
generator.watchTaskDeps[2].should.be.equal('\'inject\'');
7970
});
8071
});
8172

0 commit comments

Comments
 (0)