Skip to content

Conversation

@mbriggs
Copy link

@mbriggs mbriggs commented Nov 6, 2019

This is an extremely minor change to allow for reading package.json in a non root location. I am doing client work on a massive repository, and frequently will :cd into a project directory when I am working on it in order to have a sane fzf experience :)


function! test#javascript#has_package(package) abort
for line in readfile('package.json')
let json_path = findfile('package.json', '.;')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should get this to exclude node_modules as that will contain main package.json files

@codeinabox
Copy link
Collaborator

Thank you for this pull request. My only reservation is we might need to update all the runners as they presume that the node_modules directory which can contain the test runner binary is in the current working directory.

@ShahinSorkh
Copy link
Contributor

I guess you can use npx or yarn dlx to run the runner instead of checking a hard-coded path.
It will check the project root if find one, and then will install the requested runner if is not installed as a dependency.

@ShahinSorkh
Copy link
Contributor

yarn dlx: https://yarnpkg.com/cli/dlx
npx: https://www.npmjs.com/package/npx

Note: npx is usually bundled with npm.

@fnune
Copy link

fnune commented Nov 9, 2020

This patch makes vim-test work on my monorepo!

@adrianhelvikspond
Copy link

For jest it looks like it doesn't call jest from the correct directory. So while it finds package.json and determines the test runner correctly, I get the error command not found: jest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants