Comments (9)
To me, "no extension" means "a script I can execute from the command line". In other words, I try to avoid a file extension for any file with a shebang at the top and chmod +x
applied to it. Maybe that's just me though! 🤷
If it helps, here's an example of how another project recently accomplished this: code, issue.
from zx.
Actually we can make a workaround this problem by writing script with extension to separate file and executing it.
from zx.
It will cool to have VSCode extension for zx. And with it we can allow omitting extension.
from zx.
Done!
from zx.
Actually we can make a workaround this problem by writing script with extension to separate file and executing it.
Thank you for implementing this feature.
Right now the mjs script is generated in the same folder as the executable, and it is cleaned up when the script exits. But if you close the script midway with ctrl + c, or any type of process.exit() is executed from within the script, this generated file is unfortunately not cleaned up. Moreover, in future invocations (and possible cancellations) newer and newer files are generated (with random suffixes to prevent clashes) and they pile up.
Is there a particular reason for generating this temporary file in the same location as the original script? I don't think making sure that the cleanup happens properly in each case would be trivial (or possible). Would it be better to generate this in a system's temp folder so that no matter what happens, they are cleaned by the system automatically? If such a change makes sense, maybe I can attempt a PR for it.
from zx.
With you have .mjs
or .js
editors will understand 😉
Also, mjs/js makes the distinction between ESM/CommonJS modules.
It's possible to add support for "empty extension", but I think the explicit extension is better.
from zx.
Concrete use case:
At my company we share a lot of tools. We put common scripts in a bin folder. These are written in the language most suitable for the task and it should be easy to replace these scripts with a new implementation as requirements change. Therefore, there can be no file extension in our script files.
The shebang should be plenty to go on for syntax highlighting. I respect that tooling isn't really there yet but it should be up to the users of this.
from zx.
A quick workaround for this is that use a new shell script.
For example , assume that you've written a script called foo.mjs
but you want to invoke it without extension i.e. foo
. Then you could write a shell script called foo
with content like this:
#!/usr/bin/env bash
zx /path/to/foo.mjs
Then put it into somewhere in your $PATH.
As far as I know, the mjs file extension is a must for Nodejs import statement. Here is the doc esm import specifiers .
from zx.
That would be nice! For me (and probably others) the temp files will most likely be exposed on the PATH, since the original file was exposed through it's containing folder. This will contaminate a lot of stuff, autocompletion, for instance.
from zx.
Related Issues (20)
- Drop Node.js v16 and node-fetch dependency HOT 1
- `which` utility not working correctly when using `$.prefix`
- feature request: trim option HOT 11
- feature request: shorter commands for common patterns HOT 1
- windows execution failed
- Feature request: hiding user input HOT 2
- Template strings have some parsing bugs HOT 1
- Imported `argv` includes the filename
- Feature request: support "minutes" for duration
- ssh() is undocumented HOT 1
- ssh() fails: "Control socket connect" HOT 1
- Shell variable in args array not expanded HOT 2
- Feature request: Process Promise verbose() HOT 1
- Self-introduction: GitHub Action `run-zx`
- Reduce package installation size HOT 3
- Feature request: nothrow() only for a subset of error codes
- Allow multiple lines of hashbangs
- $`readlink` always throws error HOT 2
- An easy way to specify stdin HOT 3
- Replacing globby with a lighter alternative HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zx.