ava icon indicating copy to clipboard operation
ava copied to clipboard

Ensure watch mode works when AVA is called outside the package root

Open novemberborn opened this issue 10 years ago • 9 comments

Issuehunt badges

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 novemberborn has been rewarded.

Backers (Total: $40.00)

Submitted pull Requests


Tips

novemberborn avatar Jun 26 '16 16:06 novemberborn

See also #937, which may just be why watch mode isn't working as it should.

novemberborn avatar Jun 26 '16 16:06 novemberborn

@novemberborn I this related to https://github.com/avajs/ava/issues/32#issuecomment-216117267 Would fixing that issue help this case?

sindresorhus avatar Jun 29 '16 13:06 sindresorhus

@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).

novemberborn avatar Jun 29 '16 20:06 novemberborn

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?

timurtu avatar Aug 18 '16 04:08 timurtu

This is PR welcome again, as #985 went stale. Make sure to take into account the feedback left in #985.

sindresorhus avatar Nov 17 '16 10:11 sindresorhus

@issuehunt has funded $40.00 to this issue.


IssueHuntBot avatar May 15 '19 05:05 IssueHuntBot

@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 ..

isSource

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 )

fileStartsWith

okandas avatar May 28 '19 22:05 okandas

I've refactored the file selection and classification logic. I'm not sure if this bug still exists.

novemberborn avatar Jun 01 '19 08:06 novemberborn

@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

issuehunt-oss[bot] avatar May 12 '26 14:05 issuehunt-oss[bot]