1
1
"use strict" ;
2
2
3
+ var fs = require ( 'fs' ) ;
4
+ var _ = require ( 'lodash' ) ;
5
+ var stripJsonComments = require ( 'strip-json-comments' ) ;
6
+
3
7
var gulp = require ( 'gulp' ) ;
4
8
var log = require ( 'gulp-util' ) . log ;
5
9
var concat = require ( 'gulp-concat' ) ;
@@ -25,6 +29,23 @@ var ignoredFiles = '!src/angular.bind.js';
25
29
var assets = 'app/assets/**/*' ;
26
30
27
31
32
+ var getJshintConfig = function ( filepath ) {
33
+ return JSON . parse ( stripJsonComments ( fs . readFileSync ( filepath , { encoding : 'utf-8' } ) ) ) ;
34
+ } ;
35
+
36
+ var getMergedJshintConfig = function ( filepath ) {
37
+ // "extends" doesn't work in configuration passed by an object, we need to do the extending ourselves.
38
+ var config = getJshintConfig ( filepath ) ;
39
+ var baseConfig = getJshintConfig ( '../.jshintrc-base' ) ;
40
+ _ . merge ( config , baseConfig ) ;
41
+ delete config . extends ;
42
+
43
+ // Examples don't run in strict mode; accept that for now.
44
+ config . strict = false ;
45
+
46
+ return config ;
47
+ } ;
48
+
28
49
var copyComponent = function ( component , pattern , sourceFolder , packageFile ) {
29
50
pattern = pattern || '/**/*' ;
30
51
sourceFolder = sourceFolder || bowerFolder ;
@@ -90,17 +111,35 @@ gulp.task('assets', ['bower'], function() {
90
111
91
112
gulp . task ( 'doc-gen' , [ 'bower' ] , function ( ) {
92
113
var dgeni = new Dgeni ( [ require ( './config' ) ] ) ;
93
- return dgeni . generate ( ) . catch ( function ( error ) {
114
+ return dgeni . generate ( ) . catch ( function ( ) {
94
115
process . exit ( 1 ) ;
95
116
} ) ;
96
117
} ) ;
97
118
98
119
// JSHint the example and protractor test files
99
120
gulp . task ( 'jshint' , [ 'doc-gen' ] , function ( ) {
100
- gulp . src ( [ outputFolder + '/ptore2e/**/*.js' , outputFolder + '/examples/**/*.js' ] )
101
- . pipe ( jshint ( ) )
102
- . pipe ( jshint . reporter ( 'jshint-stylish' ) )
103
- . pipe ( jshint . reporter ( 'fail' ) ) ;
121
+ var examplesConfig = getMergedJshintConfig ( '../docs/app/test/.jshintrc' ) ;
122
+ // Some tests use `alert` which is not assumed to be available even with `"browser": true`.
123
+ examplesConfig . globals . alert = false ;
124
+
125
+ var protractorConfig = getMergedJshintConfig ( '../docs/app/e2e/.jshintrc' ) ;
126
+
127
+ return merge (
128
+ gulp . src ( [
129
+ outputFolder + '/examples/**/*.js' ,
130
+ '!' + outputFolder + '/examples/**/protractor.js' ,
131
+ ] )
132
+ . pipe ( jshint ( examplesConfig ) )
133
+ . pipe ( jshint . reporter ( 'jshint-stylish' ) )
134
+ . pipe ( jshint . reporter ( 'fail' ) ) ,
135
+ gulp . src ( [
136
+ outputFolder + '/ptore2e/**/*.js' ,
137
+ outputFolder + '/examples/**/protractor.js' ,
138
+ ] )
139
+ . pipe ( jshint ( protractorConfig ) )
140
+ . pipe ( jshint . reporter ( 'jshint-stylish' ) )
141
+ . pipe ( jshint . reporter ( 'fail' ) )
142
+ ) ;
104
143
} ) ;
105
144
106
145
0 commit comments