Skip to content
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

Add test watching #40

Closed
wants to merge 2 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
Empty file modified bin/create-elm-app-cli.js
100644 → 100755
Empty file.
33 changes: 27 additions & 6 deletions bin/global-cli.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ const executablePaths = require('elm/platform').executablePaths;
const version = require('../package.json').version;
const elmPlatformVersion = require('../node_modules/elm/package.json').version;
const paths = require('../config/paths');
const chokidar = require('chokidar');

function help (version) {
console.log('\nUsage: elm-app <command>\n');
console.log('where <command> is one of:');
console.log(' create, build, start, package, reactor, make, repl\n');
console.log(' create, build, start, package, reactor, make, repl, test\n');
console.log('\nElm ' + elmPlatformVersion + '\n');
console.log('create-elm-app@' + version + ' ' + path.resolve(__dirname, '..'));
}
Expand All @@ -24,6 +25,14 @@ if (commands.length === 0) {

var script = commands[ 0 ];

function runTests() {
spawn.sync(
path.resolve(__dirname, '..', 'node_modules/elm-test/bin/elm-test'),
[ '--compiler', path.normalize(executablePaths['elm-make']) ],
{ stdio: 'inherit' }
);
}

switch (script) {
case 'create':
spawn.sync(
Expand Down Expand Up @@ -57,11 +66,23 @@ switch (script) {
break;

case 'test':
spawn.sync(
path.resolve(__dirname, '..', 'node_modules/elm-test/bin/elm-test'),
[ '--compiler', path.normalize(executablePaths['elm-make']) ],
{ stdio: 'inherit' }
);
if (argv.w === true || argv.watch === true) {
const watcher = chokidar.watch(argv.watchGlob || '**/*.elm', {
ignored: /elm-stuff/,
awaitWriteFinish: {
stabilityThreshold: 150,
}
});

console.log('Watching your files for changes before running any tests.');

watcher.on('change', function(path) {
console.log('File', path, 'changed, rerunning tests.');
runTests();
});
} else {
runTests();
}
break;
default:

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"autoprefixer": "^6.5.2",
"bluebird": "^3.4.6",
"chalk": "^1.1.3",
"chokidar": "1.6.1",
"clean-webpack-plugin": "^0.1.14",
"cli-table": "0.3.1",
"cross-spawn": "^5.0.1",
Expand Down