Ability to execute files with shebang on Windows and older versions of Ubuntu?
For example, say you had:
{
"tasks": {
"my_task": "./my_script.js"
}
}
And the script had:
#!/usr/bin/env -S deno run --unstable --allow-write --allow-read --allow-run
// ...etc...
Perhaps if the script has a shebang starting with #!/usr/bin/env -S then deno task should just figure this out. This apparently already works on Mac so making this work on all platforms would reduce some issues.
From @jespertheend in https://github.com/denoland/deno/discussions/14036
I like this method because it keeps the required permissions close to the actual file, and running the script is extremely simple because all you have to do is run ./tools/format.js.
But the downside is... it doesn't work very well on Windows. Maybe I'm missing a simple solution for this, but as far as I can tell /usr/bin/env is not really a thing on Windows, and shebang support isn't great either. So Windows users are stuck with having to run scripts using deno run while trying to figure out what the required permissions are (or running with -A). This wasn't a huge problem for me though. I'm mostly developing on macOS, so I was using shebangs for now, though I did want to have better cross platform support eventually.
To implement this, I think we should attempt to parse the shebang. If we can, execute it the same way on all platforms. If we can't, we should try to run it as a command, but print a warning saying it won't work cross platform and to recommend fixing the shebang.