Skip to content

Commit

Permalink
Prefer the locally installed version of AVA.
Browse files Browse the repository at this point in the history
This hunts for AVA in the locally installed project, and runs that
CLI instead of the globally installed one.

Fixes avajs#157.
  • Loading branch information
jamestalmage committed Nov 29, 2015
1 parent 306f28d commit 2f7ac92
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@

var debug = require('debug')('ava');

// Prefer the local installation of AVA.
var resolveFrom = require('resolve-from');
var localCLI = resolveFrom('.', 'ava/cli');

if (localCLI && localCLI !== __filename) {
debug('Using local install of AVA.');
require(localCLI);
return;
}

if (debug.enabled) {
require('time-require');
}
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"power-assert-renderers": "^0.1.0",
"pretty-ms": "^2.0.0",
"require-from-string": "^1.1.0",
"resolve-from": "^1.0.0",
"resolve-from": "^2.0.0",
"serialize-error": "^1.1.0",
"set-immediate-shim": "^1.0.1",
"source-map-support": "^0.3.3",
Expand All @@ -128,5 +128,10 @@
"test[/\\\\]"
]
}
},
"xo": {
"ignore": [
"cli.js"
]
}
}
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ $ ava --help

Files starting with `_` are ignored. This can be useful for having helpers in the same directory as your test files.

*WARNING: NON-STANDARD BEHAVIOR:* The AVA CLI will always try to find and use your projects local install of AVA. This is true even when you run the global `ava` command. This non-standard behavior solves an important [issue](https://github.com/sindresorhus/ava/issues/157), and should have no impact on everyday use.

## Documentation

Expand Down

0 comments on commit 2f7ac92

Please sign in to comment.