Skip to content

Commit 362a094

Browse files
pksunkarachrisvfritz
authored andcommitted
Don't add test.env.js if no tests (vuejs-templates#294)
1 parent ca7bcdf commit 362a094

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

meta.json renamed to meta.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
{
1+
module.exports = {
2+
"helpers": {
3+
"if_or": function (v1, v2, options) {
4+
if (v1 || v2) {
5+
return options.fn(this);
6+
}
7+
8+
return options.inverse(this);
9+
}
10+
},
211
"prompts": {
312
"name": {
413
"type": "string",
@@ -69,8 +78,9 @@
6978
"filters": {
7079
".eslintrc.js": "lint",
7180
".eslintignore": "lint",
81+
"config/test.env.js": "unit || e2e",
7282
"test/unit/**/*": "unit",
7383
"test/e2e/**/*": "e2e"
7484
},
7585
"completeMessage": "To get started:\n\n cd {{destDirName}}\n npm install\n npm run dev\n\nDocumentation can be found at https://vuejs-templates.github.io/webpack"
76-
}
86+
};

template/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ npm run unit
2323
# run e2e tests
2424
npm run e2e
2525
{{/e2e}}
26+
{{#if_or unit e2e}}
2627

2728
# run all tests
2829
npm test
30+
{{/if_or}}
2931
```
3032

3133
For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).

template/build/dev-server.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ var webpack = require('webpack')
44
var config = require('../config')
55
var opn = require('opn')
66
var proxyMiddleware = require('http-proxy-middleware')
7-
var webpackConfig = process.env.NODE_ENV === 'testing'
7+
var webpackConfig = {{#if_or unit e2e}}process.env.NODE_ENV === 'testing'
88
? require('./webpack.prod.conf')
9-
: require('./webpack.dev.conf')
9+
: {{/if_or}}require('./webpack.dev.conf')
1010

1111
// default port where dev server listens for incoming traffic
1212
var port = process.env.PORT || config.dev.port

template/build/webpack.prod.conf.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ var merge = require('webpack-merge')
66
var baseWebpackConfig = require('./webpack.base.conf')
77
var ExtractTextPlugin = require('extract-text-webpack-plugin')
88
var HtmlWebpackPlugin = require('html-webpack-plugin')
9-
var env = process.env.NODE_ENV === 'testing'
9+
var env = {{#if_or unit e2e}}process.env.NODE_ENV === 'testing'
1010
? require('../config/test.env')
11-
: config.build.env
11+
: {{/if_or}}config.build.env
1212

1313
var webpackConfig = merge(baseWebpackConfig, {
1414
module: {
@@ -43,9 +43,9 @@ var webpackConfig = merge(baseWebpackConfig, {
4343
// you can customize output by editing /index.html
4444
// see https://github.com/ampedandwired/html-webpack-plugin
4545
new HtmlWebpackPlugin({
46-
filename: process.env.NODE_ENV === 'testing'
46+
filename: {{#if_or unit e2e}}process.env.NODE_ENV === 'testing'
4747
? 'index.html'
48-
: config.build.index,
48+
: {{/if_or}}config.build.index,
4949
template: 'index.html',
5050
inject: true,
5151
minify: {

template/package.json

+4-8
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@
66
"private": true,
77
"scripts": {
88
"dev": "node build/dev-server.js",
9-
"build": "node build/build.js",
10-
{{#unit}}
11-
"unit": "karma start test/unit/karma.conf.js --single-run",
12-
{{/unit}}
13-
{{#e2e}}
14-
"e2e": "node test/e2e/runner.js",
15-
{{/e2e}}
16-
"test": "{{#unit}}npm run unit{{/unit}}{{#unit}}{{#e2e}} && {{/e2e}}{{/unit}}{{#e2e}}npm run e2e{{/e2e}}"{{#lint}},
9+
"build": "node build/build.js"{{#unit}},
10+
"unit": "karma start test/unit/karma.conf.js --single-run"{{/unit}}{{#e2e}},
11+
"e2e": "node test/e2e/runner.js"{{/e2e}}{{#if_or unit e2e}},
12+
"test": "{{#unit}}npm run unit{{/unit}}{{#unit}}{{#e2e}} && {{/e2e}}{{/unit}}{{#e2e}}npm run e2e{{/e2e}}"{{/if_or}}{{#lint}},
1713
"lint": "eslint --ext .js,.vue src{{#unit}} test/unit/specs{{/unit}}{{#e2e}} test/e2e/specs{{/e2e}}"{{/lint}}
1814
},
1915
"dependencies": {

0 commit comments

Comments
 (0)