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

map "deno run X" to "deno task X" if X is not a script #24307

Open
ry opened this issue Jun 21, 2024 · 4 comments
Open

map "deno run X" to "deno task X" if X is not a script #24307

ry opened this issue Jun 21, 2024 · 4 comments
Labels
feat new feature (which has been agreed to/accepted)

Comments

@ry
Copy link
Member

ry commented Jun 21, 2024

will require changes across the stack to properly detect if module is not found. When I tried that before it didn't work well relying on just error message
deno_graph and probably deno_npm need to return concrete error types and not be casted to a generic AnyError

@ry ry added the feat new feature (which has been agreed to/accepted) label Jun 21, 2024
@yazan-abdalrahman
Copy link

@ry

Hello, I'm trying to invistegate this featuer, maybe i can work on it. We need to see if the X 'deno execute X' is not a script by checking if it not has any endings with '.ts || .js' I will print a message to inform 'the X it was task not script' and then run 'deno task X', but from where it would search on task? I believe it should exist deno.json to specify the tasks.

do you have some behavior or expected logic of it task?

@yazan-abdalrahman
Copy link

@ry
Can we modify the Custom Error in deno_core to return 'class' attribute that will help determine script not found? Then, if it is 'not found' and the flag it 'run', it will map it to task.

[cli\main.rs:347:7] &err = CustomError {
class: "NotFound",
message: "Module not found "file:///D:/yad/deno/task/start".",
}
?

Please let me know whether I can use this solution or tell me what to expect.

@BlackAsLight
Copy link

We need to see if the X 'deno execute X' is not a script by checking if it not has any endings with '.ts || .js'

This method is flawed. A file doesn't need an extension or could have a different extension and still be valid JavaScript/TypeScript code.

then run 'deno task X', but from where it would search on task? I believe it should exist deno.json to specify the tasks.

Either deno.json or deno.jsonc

@yazan-abdalrahman
Copy link

We need to see if the X 'deno execute X' is not a script by checking if it not has any endings with '.ts || .js'

This method is flawed. A file doesn't need an extension or could have a different extension and still be valid JavaScript/TypeScript code.

then run 'deno task X', but from where it would search on task? I believe it should exist deno.json to specify the tasks.

Either deno.json or deno.jsonc

@BlackAsLight
Hello, sure, I checked it yesterday and I know we can't use that method.

so,Can we modify the Custom Error in deno_core to return 'class' attribute that will help determine script not found? Then, if it is 'not found' and the flag it 'run', it will map it to task.

[cli\main.rs:347:7] &err = CustomError {
class: "NotFound",
message: "Module not found "file:///D:/yad/deno/task/start".",
}
?

Please let me know whether I can use this solution or tell me what to expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat new feature (which has been agreed to/accepted)
Projects
None yet
Development

No branches or pull requests

3 participants