-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Node.js-style --require CLI argument #296
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ if (debug.enabled) { | |
require('time-require'); | ||
} | ||
|
||
var arrify = require('arrify'); | ||
var meow = require('meow'); | ||
var updateNotifier = require('update-notifier'); | ||
var chalk = require('chalk'); | ||
|
@@ -35,6 +36,7 @@ var cli = meow([ | |
' --init Add AVA to your project', | ||
' --fail-fast Stop after first test failure', | ||
' --serial Run tests serially', | ||
' --require Module to preload (Can be repeated)', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be updated in the readme.md too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
'', | ||
'Examples', | ||
' ava', | ||
|
@@ -46,7 +48,10 @@ var cli = meow([ | |
'Default patterns when no arguments:', | ||
'test.js test-*.js test/*.js' | ||
], { | ||
string: ['_'], | ||
string: [ | ||
'_', | ||
'require' | ||
], | ||
boolean: [ | ||
'fail-fast', | ||
'serial' | ||
|
@@ -64,7 +69,8 @@ log.write(); | |
|
||
var api = new Api(cli.input, { | ||
failFast: cli.flags.failFast, | ||
serial: cli.flags.serial | ||
serial: cli.flags.serial, | ||
require: arrify(cli.flags.require) | ||
}); | ||
|
||
api.on('test', function (test) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,11 @@ if (debug.enabled) { | |
// Bind globals first, before anything has a chance to interfere. | ||
var globals = require('./globals'); | ||
|
||
var resolveCwd = require('resolve-cwd'); | ||
(opts.require || []).forEach(function (moduleId) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think https://github.com/sindresorhus/ava/pull/296/files#diff-2cce40143051e25f811b56c79d619bf5R73 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope. In the API tests, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, never mind then. I read it wrong. |
||
require(resolveCwd(moduleId)); | ||
}); | ||
|
||
var sourceMapCache = Object.create(null); | ||
|
||
var sourceMapSupport = require('source-map-support'); | ||
|
@@ -33,7 +38,6 @@ sourceMapSupport.install({ | |
var createEspowerPlugin = require('babel-plugin-espower/create'); | ||
var requireFromString = require('require-from-string'); | ||
var loudRejection = require('loud-rejection/api')(process); | ||
var resolveCwd = require('resolve-cwd'); | ||
var hasGenerator = require('has-generator'); | ||
var serializeError = require('serialize-error'); | ||
var send = require('./send'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global.foo = 'bar'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import test from '../../'; | ||
|
||
test(t => t.is(global.foo, 'bar')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already fixed this in 3fdf44d, sorry. Can you rebase to fix the merge conflict?