Skip to content

Commit b8299ea

Browse files
committed
feat(webpack): Add support for webpack
Also changed code style to use npm standard package to lint js - this is non-configurable and does not allow semicolons.
1 parent 54bafe7 commit b8299ea

13 files changed

+840
-769
lines changed

.jscsrc

-8
This file was deleted.

gulpfile.js

+66-74
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,80 @@
1-
/*globals require, __dirname */
1+
/* globals require, __dirname */
22
/* jshint node:true */
3-
'use strict';
3+
'use strict'
44

5-
var gulp = require('gulp');
6-
var jscs = require('gulp-jscs');
7-
var jshint = require('gulp-jshint');
8-
var karmaConfig = __dirname + '/karma.conf.js';
9-
var lodash = require('lodash');
10-
var paths = require('./paths');
11-
var plato = require('plato');
12-
var Server = require('karma').Server;
5+
var gulp = require('gulp')
6+
var lodash = require('lodash')
7+
var path = require('path')
8+
var paths = require('./paths')
9+
var plato = require('plato')
10+
var Server = require('karma').Server
11+
var standard = require('gulp-standard')
1312

14-
gulp.task('clean', function () {
15-
16-
var del = require('del');
17-
return del([
18-
'build'
19-
]);
20-
});
13+
var karmaConfig = path.join(__dirname, 'karma.conf.js')
2114

22-
gulp.task('default', ['clean:mobile']);
15+
gulp.task('clean', function () {
16+
var del = require('del')
17+
return del([
18+
'build'
19+
])
20+
})
2321

2422
gulp.task('complexity', function (done) {
23+
var callback = function () {
24+
done()
25+
}
2526

26-
var callback = function () {
27-
done();
28-
};
29-
30-
plato.inspect(paths.lint, 'build/complexity', {title: 'prerender', recurse: true}, callback);
31-
});
32-
33-
gulp.task('jscs', function () {
34-
return gulp
35-
.src(paths.lint)
36-
.pipe(jscs('.jscsrc'));
37-
});
27+
plato.inspect(paths.lint, 'build/complexity', {title: 'prerender', recurse: true}, callback)
28+
})
3829

3930
gulp.task('lint', function () {
40-
return gulp
41-
.src(paths.lint)
42-
.pipe(jshint('.jshintrc'))
43-
.pipe(jshint.reporter('default', {verbose: true}))
44-
.pipe(jshint.reporter('jshint-stylish'))
45-
.pipe(jshint.reporter('fail'));
46-
});
47-
48-
var testConfig = function (options) {
49-
var travisOptions = process.env.TRAVIS &&
50-
{
51-
browsers: ['Firefox'],
52-
reporters: ['dots', 'coverage', 'threshold']
53-
};
54-
55-
return lodash.assign(options, travisOptions);
56-
};
31+
return gulp
32+
.src(paths.lint)
33+
.pipe(standard())
34+
.pipe(standard.reporter('default', {
35+
breakOnError: true,
36+
quiet: true
37+
}))
38+
})
5739

5840
gulp.task('tdd', function (done) {
59-
gulp.watch(paths.all, ['jscs', 'lint']);
60-
61-
var config = testConfig(
62-
{
63-
autoWatch: true,
64-
browsers: ['PhantomJS'],
65-
configFile: karmaConfig,
66-
singleRun: false
67-
}
68-
);
41+
gulp.watch(paths.all, ['jscs', 'lint'])
42+
43+
var config = testConfig(
44+
{
45+
autoWatch: true,
46+
browsers: ['PhantomJS'],
47+
configFile: karmaConfig,
48+
singleRun: false
49+
}
50+
)
51+
52+
var server = new Server(config, done)
53+
server.start()
54+
})
55+
56+
gulp.task('test', ['lint'], function (done) {
57+
var config = testConfig(
58+
{
59+
configFile: karmaConfig,
60+
singleRun: true,
61+
reporters: ['progress', 'coverage', 'threshold']
62+
}
63+
)
64+
65+
var server = new Server(config, done)
66+
server.start()
67+
})
68+
69+
gulp.task('default', ['complexity', 'test'])
6970

70-
var server = new Server(config, done);
71-
server.start();
72-
});
73-
74-
gulp.task('test', ['jscs', 'lint'], function (done) {
75-
76-
var config = testConfig(
77-
{
78-
configFile: karmaConfig,
79-
singleRun: true,
80-
reporters: ['progress', 'coverage', 'threshold']
81-
}
82-
);
71+
var testConfig = function (options) {
72+
var travisDefaultOptions = {
73+
browsers: ['Firefox'],
74+
reporters: ['dots', 'coverage', 'threshold']
75+
}
8376

84-
var server = new Server(config, done);
85-
server.start();
86-
});
77+
var travisOptions = process.env.TRAVIS && travisDefaultOptions
8778

88-
gulp.task('default', ['complexity', 'test']);
79+
return lodash.assign(options, travisOptions)
80+
}

karma.conf.js

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*globals require */
1+
/* globals require */
22
/* jshint node:true */
33

44
/**
@@ -13,11 +13,11 @@
1313
* @since 7/21/13
1414
*/
1515

16-
17-
var paths = require('./paths');
16+
var paths = require('./paths')
1817

1918
module.exports = function (config) {
20-
'use strict';
19+
'use strict'
20+
2121
config.set({
2222

2323
frameworks: ['jasmine'],
@@ -53,7 +53,6 @@ module.exports = function (config) {
5353
// possible values: 'dots', 'progress', 'junit'
5454
reporters: ['progress', 'coverage'],
5555

56-
5756
// the configure thresholds
5857
thresholdReporter: {
5958
statements: 100,
@@ -65,24 +64,19 @@ module.exports = function (config) {
6564
// web server port
6665
port: 9876,
6766

68-
6967
// cli runner port
7068
runnerPort: 9100,
7169

72-
7370
// enable / disable colors in the output (reporters and logs)
7471
colors: true,
7572

76-
7773
// level of logging
7874
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
7975
logLevel: config.LOG_INFO,
8076

81-
8277
// enable / disable watching file and executing tests whenever any file changes
8378
autoWatch: false,
8479

85-
8680
// Start these browsers, currently available:
8781
// - Chrome
8882
// - ChromeCanary
@@ -93,13 +87,11 @@ module.exports = function (config) {
9387
// - IE (only Windows)
9488
browsers: ['PhantomJS'],
9589

96-
9790
// If browser does not capture in given timeout [ms], kill it
9891
captureTimeout: 60000,
9992

100-
10193
// Continuous Integration mode
10294
// if true, it capture browsers, run tests and exit
10395
singleRun: false
104-
});
105-
};
96+
})
97+
}

package.json

+19-15
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,40 @@
2222
"angular-mocks": "^1.x",
2323
"coveralls": "^2.11.6",
2424
"cz-conventional-changelog": "^1.1.5",
25-
"eslint": "^2.2.0",
26-
"grunt-bump": "^0.7.0",
25+
"eslint": "^3.5.0",
26+
"grunt-bump": "^0.8.0",
2727
"gulp": "^3.8.11",
28-
"gulp-htmlmin": "^1.3.0",
29-
"gulp-jscs": "^3.0.2",
28+
"gulp-htmlmin": "^2.0.0",
29+
"gulp-jscs": "^4.0.0",
3030
"gulp-jshint": "^2.0.0",
31+
"gulp-standard": "^8.0.2",
3132
"jasmine-core": "^2.4.1",
32-
"jquery": "^2.2.0",
33+
"jquery": "^3.1.0",
3334
"jshint": "^2.9.1",
3435
"jshint-stylish": "^2.1.0",
35-
"karma": "^0.13.21",
36-
"karma-chrome-launcher": "^0.2.2",
37-
"karma-coverage": "^0.5.3",
38-
"karma-firefox-launcher": "^0.1.7",
39-
"karma-jasmine": "^0.3.7",
36+
"karma": "^1.3.0",
37+
"karma-chrome-launcher": "^2.0.0",
38+
"karma-coverage": "^1.1.1",
39+
"karma-firefox-launcher": "^1.0.0",
40+
"karma-jasmine": "^1.0.2",
4041
"karma-phantomjs-launcher": "^1.0.0",
4142
"karma-threshold-reporter": "^0.1.12",
43+
"karma-webpack": "^1.8.0",
4244
"lodash": "^4.5.0",
4345
"phantomjs-prebuilt": "^2.1.4",
4446
"plato": "^1.5.0",
4547
"run-browser": "^2.0.2",
46-
"semantic-release": "^6.2.0",
47-
"standard": "^6.0.7",
48-
"tape": "^4.4.0"
48+
"semantic-release": "^6.3.0",
49+
"standard": "^8.0.0",
50+
"tape": "^4.4.0",
51+
"webpack": "^1.13.2"
4952
},
5053
"scripts": {
51-
"test": "npm run test-browserify && gulp",
5254
"coverage:upload": "cat build/coverage/lcov.info | coveralls",
55+
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
56+
"test": "npm run test-browserify && npm run test-webpack && gulp",
5357
"test-browserify": "run-browser test/commonjs/browserify.test.js -b",
54-
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
58+
"test-webpack": "karma start test/webpack/karma.conf.js"
5559
},
5660
"repository": {
5761
"type": "git",

paths.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
/* jshint node:true */
22

3-
var bower = [
3+
var nodeModules = [
44
'node_modules/jquery/dist/jquery.js',
55
'node_modules/moment/moment.js',
66
'node_modules/angular/angular.js',
77
'node_modules/angular-mocks/angular-mocks.js'
8-
];
9-
var bumpFiles = ['package.json', 'bower.json', 'README.md', 'src/js/*.js'];
10-
var miscFiles = ['GruntFile.js', 'gulpfile.js', 'karma.conf.js', 'paths.js'];
11-
var demoFiles = [];
12-
var sourceFiles = ['src/**/*.js'];
13-
var testFiles = ['test/**/*.spec.js'];
8+
]
9+
var bumpFiles = ['package.json', 'bower.json', 'README.md', 'src/js/*.js']
10+
var miscFiles = ['GruntFile.js', 'gulpfile.js', 'karma.conf.js', 'paths.js']
11+
var demoFiles = []
12+
var sourceFiles = ['src/**/*.js']
13+
var testFiles = ['test/**/*.spec.js']
1414

1515
module.exports = {
16-
all: bower.concat(sourceFiles).concat(testFiles).concat(demoFiles),
16+
all: nodeModules.concat(sourceFiles).concat(testFiles).concat(demoFiles),
1717
app: sourceFiles,
1818
bump: bumpFiles,
1919
lint: miscFiles.concat(sourceFiles).concat(testFiles).concat(miscFiles),
2020
src: sourceFiles,
2121
test: testFiles
22-
};
22+
}

0 commit comments

Comments
 (0)