Ensure watch mode works when AVA is called outside the package root
Given the following project layout:
/package.json
/lib/foo.js
/test/foo.js
Watch mode works as expected when invoked like this:
cd /
$(npm bin)/ava -w test/foo.js
But not if invoked like:
cd /test
$(npm bin)/ava -w foo.js
See also #863.
IssueHunt Summary
novemberborn has been rewarded.
Backers (Total: $40.00)
issuehunt ($40.00)
Submitted pull Requests
Tips
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on IssueHunt to raise funds.
See also #937, which may just be why watch mode isn't working as it should.
@novemberborn I this related to https://github.com/avajs/ava/issues/32#issuecomment-216117267 Would fixing that issue help this case?
@sindresorhus no, the watcher runs in the main thread. The CLI behaves differently with watch mode depending on the directory you're in when you start it. This has been fixed for non-watch mode (#863).
Hello, I'd like to contribute if anyone else hasn't taken this. By outside package root do you mean calling './(project-root)/node_modules/.bin/ava -w' from a shell (or child_process) isn't working?
This is PR welcome again, as #985 went stale. Make sure to take into account the feedback left in #985.
@issuehunt has funded $40.00 to this issue.
- Submit pull request via IssueHunt to receive this reward.
- Want to contribute? Chip in to this issue via IssueHunt.
- Checkout the IssueHunt Issue Explorer to see more funded issues.
- Need help from developers? Add your repository on IssueHunt to raise funds.
@novemberborn running
cd /
$(npm bin)/ava -w test/foo.js
this line will check if the files in watch are a true source this.avaFiles.isSource(filePath) and return true if its indeed a source file ..
Once inside the isSource method I wanted to check the difference between calling
$(npm bin)/ava -w test/foo.js
and
$(npm bin)/ava -w foo.js
by logging as below
// Ignore paths outside the current working directory.
// They can't be matched to a pattern.
if (filePath.startsWith('../')) {
console.log(filePath)
console.log('returns false because ignores paths outside the current working directory')
return false;
}
and this is what I got
( $(npm bin)/ava -w test/foo.js )
node_modules/ava/index.js
node_modules/ava/lib/worker/main.js
lib/foo.js
and
( $(npm bin)/ava -w foo.js )
../node_modules/ava/index.js
../node_modules/ava/lib/worker/main.js
../lib/foo.js
meaning ../lib/foo.js remains untracked as testDependecy when we call ( $(npm bin)/ava -w foo.js )
I've refactored the file selection and classification logic. I'm not sure if this bug still exists.
@sindresorhus has rewarded $36.00 to @novemberborn. See it on IssueHunt
- :moneybag: Total deposit: $40.00
- :tada: Repository reward(0%): $0.00
- :wrench: Service fee(10%): $4.00