deno task
feedback
#14036
Replies: 4 comments 5 replies
-
On Windows, I simply use vscode tasks.json.
|
Beta Was this translation helpful? Give feedback.
-
I recommend "tasks": {
"build": "deno run --unstable --allow-write --allow-read --allow-run ./build.js",
"build-dev": "deno run --unstable --allow-write --allow-read --allow-run ./build.js --dev"
} rather than pretty much ever relying on
A lot of |
Beta Was this translation helpful? Give feedback.
-
I thought about having deno task support running a task like
Yeah, this is not as ideal, but I think there might be future improvements to the permission model that could solve this.
I've heard it also doesn't work on some versions of Ubuntu.
It should be possible to leave out the
I opened #14039 to support shell completions for tasks in |
Beta Was this translation helpful? Give feedback.
-
In singular cases (i.e. on main scripts) I do (assumming my script is main.ts and I wish to call it via ln -s main.ts cli
echo "@ECHO OFF" > cli.bat
echo 'deno run --allow-env --allow-read --allow-net --ext=ts main.ts "%@"' >> cli.bat Yes, it produces more files, but a simple bat file can enable you Windows support without any hassle. I do it only for main scripts for my project. I keep using the shebang method for Unix based environments. |
Beta Was this translation helpful? Give feedback.
-
I've been using
deno task
for a bit now and the blog post was asking for feedback. I'm running into some minor usability issues so I figured I'd post them here.Introduction
First let me describe how I was running scripts before
deno task
was added. Basically all scripts have a shebang at the top of the file similar to what many of the scripts in the Deno project use:deno/tools/format.js
Lines 1 to 2 in e55dee7
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 usingdeno 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.
deno task
to the rescuedeno task
makes it possible to easily run scripts cross platform, but the benefits from the shebang method are now gone:deno task build -- --dev
is more cumbersome to write than./build.js --dev
deno task
. I guess this depends on your shell as well, but before I used to do./test.js path/to/file.test.js
, where the last part of the command would get autocompleted by my shell. This is not the case withdeno task test -- path/to/file.test.js
. I suppose this is also caused bydeno completions
being installed.Potential solutions
I'm currently using both methods, so every script has both a task configured as well as a shebang. That way Windows users can use
deno task build
and unix users can keep using./build.js
. But now there's two places where arguments need to be updated. If a developer on a unix system makes a change that requires different permissions they might only update the shebang, causing thedeno task
to break. And vice versa for developers using Windows.Perhaps something like #12763 would make this easier. Though this won't take care of other arguments such as
--unstable
. And the location of the permissions would still be separate from the main entry point.Though I think what I would prefer the most is if
deno task
were able to parse/usr/bin/env
shebangs somehow. This way the file itself could use a#!/usr/bin/env
shebang, and the configured task would only need to point to the file. Maybe a task could even look likeThis already works on unix, on Windows it gives an error. This way, unix users could keep running files like
./build.js
, and systems that don't support running files like this could use the tasks.I'm not sure how far you'd want to go with making the tasks run cross platform. Since not only would this have to be able to handle running files via
./
syntax, it would also have to parse shebangs and implement/usr/bin/env
somehow. Sounds like this is very much out of scope for Deno, but it would solve all issues mentioned above.Conclusion
Anyway, those are my ramblings. Not sure how big of an issue this really is. I could certainly live with the current situation, I just feel like DX could be better here. Maybe someone knows a neat trick that allows you to run files on Windows in a similar manner. That would eliminate the need for tasks like these altogether.
Beta Was this translation helpful? Give feedback.
All reactions