Skip to content

Commit 1328ad7

Browse files
author
benholloway
committed
parametised test glob to options.testGlob, parametised vendor.js entry path to options.appDir
1 parent 131304e commit 1328ad7

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

config/add/common.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@ var webpack = require('webpack'),
1212
* Add common features.
1313
* @this {Config} A webpack-configurator instance
1414
* @param {string} loaderRoot The base path in which to locate loaders
15-
* @param {object} globals A hash of globals
15+
* @param {{appDir:string, globals:object} globals A hash of options
1616
* @returns {Config} The given webpack-configurator instance
1717
*/
18-
function common(loaderRoot, globals) {
18+
function common(loaderRoot, options) {
1919
/* jshint validthis:true */
20+
var vendorEntry = path.resolve(options.appDir, 'test.js');
21+
2022
return this
2123
.merge({
2224
context : process.cwd(),
2325
cache : true,
2426
devtool : 'source-map',
2527
entry : {
26-
vendor: './app/vendor.js'
28+
vendor: vendorEntry
2729
},
2830
output : {
2931
filename : '[name].[chunkhash].js',
@@ -117,7 +119,7 @@ function common(loaderRoot, globals) {
117119

118120
// bower
119121
.plugin('generate-vendor', EntryGeneratorPlugin, [
120-
'./app/vendor.js',
122+
vendorEntry,
121123
EntryGeneratorPlugin.bowerDependenciesSource()
122124
])
123125
.plugin('omit-tilde', OmitTildePlugin, [{
@@ -130,7 +132,7 @@ function common(loaderRoot, globals) {
130132
}])
131133

132134
// globals
133-
.plugin('provide', webpack.ProvidePlugin, [globals])
135+
.plugin('provide', webpack.ProvidePlugin, [options.globals])
134136

135137
// output, chunking, optimisation
136138
.plugin('extract-text', ExtractTextPlugin, [

config/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function app(options) {
2626
addConditionals: require('./add/conditionals'),
2727
addMinification: require('./add/minification')
2828
})
29-
.addCommon(path.resolve(__dirname, '..', 'node_modules'), options.globals)
29+
.addCommon(path.resolve(__dirname, '..', 'node_modules'), options)
3030
.addClean(buildDir)
3131
.addComposition(composition)
3232
.addConditionals({

config/release.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function release(options) {
2525
.addBrowserSync(options.releaseDir, options.port)
2626
.addClean(options.releaseDir)
2727
.addComposition(composition)
28-
.addCommon(path.resolve(__dirname, '..', 'node_modules'), options.globals)
28+
.addCommon(path.resolve(__dirname, '..', 'node_modules'), options)
2929
.addConditionals({
3030
TEST : false,
3131
DEBUG : false,

config/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var createConfigurator = require('../lib/create-configurator');
66

77
/**
88
* Create a single webpack configurator for test.
9-
* @param {{appDir:string, testDir:string, globals:object}} options An options hash
9+
* @param {{appDir:string, testDir:string, globals:object, testGlob:string}} options An options hash
1010
* @returns {Config} A webpack configurator
1111
*/
1212
function test(options) {
@@ -17,13 +17,13 @@ function test(options) {
1717
addConditionals : require('./add/conditionals'),
1818
addTestSuiteGeneration: require('./add/test-suite-generation')
1919
})
20-
.addCommon(path.resolve(__dirname, '..', 'node_modules'), options.globals)
20+
.addCommon(path.resolve(__dirname, '..', 'node_modules'), options)
2121
.addConditionals({
2222
TEST : true,
2323
DEBUG : true,
2424
RELEASE: false
2525
})
26-
.addTestSuiteGeneration(testEntry, '**/*.spec.js')
26+
.addTestSuiteGeneration(testEntry, options.testGlob)
2727
.merge({
2828
name : 'test',
2929
entry : {

lib/default-options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ function defaultOptions() {
22
return {
33
appDir : './app',
44
buildDir : './app-build',
5-
releaseDir: './app-release',
65
testDir : './app-test',
6+
releaseDir: './app-release',
77
testGlob : '**/*.spec.js',
88
port : 55555,
99
unminified: false,

0 commit comments

Comments
 (0)