Skip to content

Commit 41b4746

Browse files
author
vdemedes
committed
fail when tests executed without cli
1 parent 3a75cb1 commit 41b4746

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

index.js

+15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
'use strict';
22
var setImmediate = require('set-immediate-shim');
33
var hasFlag = require('has-flag');
4+
var chalk = require('chalk');
5+
var relative = require('path').relative;
46
var serializeError = require('serialize-error');
57
var Runner = require('./lib/runner');
8+
var log = require('./lib/logger');
69
var runner = new Runner();
710

11+
// check if the test is being run without AVA cli
12+
var isForked = typeof process.send === 'function';
13+
14+
if (!isForked) {
15+
var path = relative('.', process.argv[1]);
16+
17+
log.write();
18+
log.error('Test files must be run with the AVA CLI:\n\n ' + chalk.grey.dim('$') + ' ' + chalk.cyan('ava ' + path) + '\n');
19+
20+
process.exit(1);
21+
}
22+
823
// if fail-fast is enabled, use this variable to detect,
924
// that no more tests should be logged
1025
var isFailed = false;

0 commit comments

Comments
 (0)