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
Allow cwd
and localDir
options to be URLs
#492
Conversation
1df332c
to
abb0ef9
Compare
test('can use `options.cwd` as a string', async t => { | ||
const cwd = '/'; | ||
const {stdout} = await execa('node', ['-p', 'process.cwd()'], {cwd}); | ||
t.is(path.toNamespacedPath(stdout), path.toNamespacedPath(cwd)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
process.cwd()
returns the drive letter on Windows, but path.normalize()
does not, so we have to use path.toNamespacedPath()
.
Default: `process.cwd()` | ||
|
||
Preferred path to find locally installed binaries in (use with `preferLocal`). | ||
|
||
Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing from the TS docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! 👍
Fixes #491
This allows the
cwd
andlocalDir
options to be URLs with thefile:
scheme.This is not available in Node.js 12. We could potentially use
fileURLToPath()
to convert it in Node.js 12. However, Node.js 12 support is ending in a little more than 2 months. Also, it would require detecting the Node.js version, which might addsemver
as a production dependency. Overall, it does not seem to be worth it, but please let me know if you think otherwise.