Skip to content

Commit f13ba2e

Browse files
committed
Merge pull request #277 from jamestalmage/prefer-local-over-global
Prefer the locally installed version of AVA.
2 parents e2e4515 + 2f7ac92 commit f13ba2e

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

cli.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33

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

6+
// Prefer the local installation of AVA.
7+
var resolveFrom = require('resolve-from');
8+
var localCLI = resolveFrom('.', 'ava/cli');
9+
10+
if (localCLI && localCLI !== __filename) {
11+
debug('Using local install of AVA.');
12+
require(localCLI);
13+
return;
14+
}
15+
616
if (debug.enabled) {
717
require('time-require');
818
}

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
"power-assert-renderers": "^0.1.0",
106106
"pretty-ms": "^2.0.0",
107107
"require-from-string": "^1.1.0",
108-
"resolve-from": "^1.0.0",
108+
"resolve-from": "^2.0.0",
109109
"serialize-error": "^1.1.0",
110110
"set-immediate-shim": "^1.0.1",
111111
"source-map-support": "^0.3.3",
@@ -128,5 +128,10 @@
128128
"test[/\\\\]"
129129
]
130130
}
131+
},
132+
"xo": {
133+
"ignore": [
134+
"cli.js"
135+
]
131136
}
132137
}

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ $ ava --help
116116

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

119+
*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.
119120

120121
## Documentation
121122

0 commit comments

Comments
 (0)