Skip to content

Test local commands #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ var autoprefixer = require('autoprefixer');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');

function isInDebugMode() {
return process.argv.some(function (item) { return item.indexOf('--debug-template') > -1 });
}

// TODO: hide this behind a flag and eliminate dead code on eject.
// This shouldn't be exposed to the user.
var isInNodeModules = 'node_modules' ===
path.basename(path.resolve(path.join(__dirname, '..', '..')));
var relativePath = isInNodeModules ? '../../..' : '..';
if (process.argv[2] === '--debug-template') {
if (isInDebugMode()) {
relativePath = '../template';
}
var srcPath = path.resolve(__dirname, relativePath, 'src');
Expand Down
6 changes: 5 additions & 1 deletion scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ var config = require('../config/webpack.config.dev');
var execSync = require('child_process').execSync;
var opn = require('opn');

function isSmokeTest() {
return process.argv.some(function (item) { return item.indexOf('--smoke-test') > -1 });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn’t process.argv.indexOf('--smoke-test') > -1 work? Same above.

Copy link
Contributor Author

@mxstbr mxstbr Jul 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because process.argv === ['something', '--debug-template --smoke-test'].

indexOf an array only works when you're looking for an entire string, e.g. if process.argv === ['something', '--smoke-test'] the indexOf('--smoke-test') will be bigger than -1.

(I thought the same thing at first, but double checked with a JSBin)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aah.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my reaction too, always learning! 😁

}

// TODO: hide this behind a flag and eliminate dead code on eject.
// This shouldn't be exposed to the user.
var handleCompile;
if (process.argv[2] === '--smoke-test') {
if (isSmokeTest()) {
handleCompile = function (err, stats) {
if (err || stats.hasErrors() || stats.hasWarnings()) {
process.exit(1);
Expand Down
18 changes: 14 additions & 4 deletions tasks/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ perl -i -p0e 's/bundledDependencies.*?]/bundledDependencies": []/s' package.json
npm install
scripts_path=$PWD/`npm pack`

# Test local start command
npm start -- --smoke-test

# Test local build command
npm run build

# Check for expected output
test -e build/*.html
test -e build/*.js

# Pack CLI
cd global-cli
npm install
Expand All @@ -50,8 +60,8 @@ cd test-app
npm run build

# Check for expected output
test -e build/*.html || exit 1
test -e build/*.js || exit 1
test -e build/*.html
test -e build/*.js

# Test the server
npm start -- --smoke-test
Expand All @@ -61,8 +71,8 @@ echo yes | npm run eject
npm run build

# Check for expected output
test -e build/*.html || exit 1
test -e build/*.js || exit 1
test -e build/*.html
test -e build/*.js

# Test the server
npm start -- --smoke-test
Expand Down