-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[Bug?]: Non .ts files in scripts/ with same name as script break exec #9249
Comments
Hi @Benjamin-Lee, thanks for reporting this! I haven't reproduced this, but can totally see why it happens. The issue is because we're using Off the top of my head, I can't think of a clean way to make it ignore the other files, but happy to hear suggestions before you start! Things to note:
|
Hey @Benjamin-Lee have you had a chance to look at a fix for this yet? Are you still interested? No pressure, just wanted an update 🙂 Have a great day! |
Hi @Tobbe and @Benjamin-Lee, I'd like to pick this up if it's alright with you? This would be my first time contributing so I may need some guidance. It seems like there are two problems/requirements:
For the first, the // - execHandler.js
const tgtScriptName = path.parse(scriptPath)?.name
const tgtMatch = findScripts()
.map((p) => path.parse(p)?.name)
.filter((n) => n == tgtScriptName) With this, we'd expect For the second requirement, we can use a similar approach to first resolve the full script path including file extension, and pass this in to the call to // - files.ts
export const resolveJSPath = (pathNoExt: string) => {
const files = fg.sync(`${pathNoExt}.{js,jsx,ts,tsx}`, {
absolute: true,
ignore: ['node_modules'],
})
if (files.length == 1) {
return files[0]
}
return false
}
// - exec.js
const script = require(resolveJSPath(scriptPath)) Questions:
|
What's not working?
Lets I have a script called
foo
inscripts/
.foo.ts
requires a data filefoo.json
, which it imports.yarn rw exec foo
now breaks. The error reference is04eeca2b-0df4-4e56-8b67-3c9d7523802b
.As a fix, one can easily rename the data file.
How do we reproduce the bug?
No response
What's your environment? (If it applies)
Are you interested in working on this?
The text was updated successfully, but these errors were encountered: