Skip to content
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

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

Closed
novemberborn opened this issue Jun 26, 2016 · 8 comments
Closed
Labels
bug current functionality does not work as desired 💵 Funded on Issuehunt This issue has been funded on Issuehunt help wanted scope:watch-mode

Comments

@novemberborn
Copy link
Member

novemberborn commented Jun 26, 2016

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.

There is a $40.00 open bounty on this issue. Add more on Issuehunt.

@novemberborn novemberborn added bug current functionality does not work as desired help wanted labels Jun 26, 2016
@novemberborn
Copy link
Member Author

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

@sindresorhus
Copy link
Member

@novemberborn I this related to #32 (comment) Would fixing that issue help this case?

@novemberborn
Copy link
Member Author

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

ltk pushed a commit to ltk/ava that referenced this issue Aug 2, 2016
ltk pushed a commit to ltk/ava that referenced this issue Aug 2, 2016
@timurtu
Copy link

timurtu commented Aug 18, 2016

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?

@sindresorhus
Copy link
Member

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

@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label May 15, 2019
@IssueHuntBot
Copy link

@IssueHunt has funded $40.00 to this issue.


@okandas
Copy link

okandas commented May 28, 2019

@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

@novemberborn
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug current functionality does not work as desired 💵 Funded on Issuehunt This issue has been funded on Issuehunt help wanted scope:watch-mode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants