I was able to use the code from this article and the denox package to create a similar npm feel. If you pass your script in as a string then split the script on the spaces to get your arguments it becomes much more usable.
If Khaled added a logical check on the config file to check if a file or script is being provided I'm sure we could achieve the desired outcome.
github.com/BentoumiTech/denox/pull/15 I took the liberty to add the functionality you're looking for. Denox is a pretty awesome package so hopefully, this gets picked up.
That's awesome. But I'm a little bit worried by this right here: const args = script.split(' ');, it doesn't handle quoted arguments. If you give it something like this
I found this package: exec. It does the same thing as that function with more options. You could use that. It only handles double quotes but it's an improvement.
If anyone is curious how they do it, here it is.
functionsplitCommand(command){varmyRegexp=/[^\s"]+|"([^"]*)"/gi;varsplits=[];do{//Each call to exec returns the next regex match as an arrayvarmatch=myRegexp.exec(command);if(match!=null){//Index 1 in the array is the captured group if it exists//Index 0 is the matched text, which we use if no captured group existssplits.push(match[1]?match[1]:match[0]);}}while(match!=null);returnsplits;}
See, the double quotes stayed, but everything else is broken. Having a bulletproof regex is a real pain. If you want to improve it, you have to modify this var myRegexp = /[^\s"]+|"([^"]*)"/gi;.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the article, I've been also working on a tool to replace npm scripts in Deno.
It uses YAML and currently supports permissions github.com/BentoumiTech/denox/
I really like the work you've done! It needs an ability to put an "on the fly" script like in package.json
AFAIK, they are going to make
denox run
as alias todenox run default
, so it's even faster to type thandenox start
. Clear and concise IMO!denon
,velociraptor
, andtrex
seem promising. I think that they have more chances to be widespread.Looks really good. I see that it can run a selected file with the permissions, but what about random commands? Is there a plan for that?
I was able to use the code from this article and the denox package to create a similar npm feel. If you pass your script in as a string then split the script on the spaces to get your arguments it becomes much more usable.
If Khaled added a logical check on the config file to check if a file or script is being provided I'm sure we could achieve the desired outcome.
github.com/BentoumiTech/denox/pull/15 I took the liberty to add the functionality you're looking for. Denox is a pretty awesome package so hopefully, this gets picked up.
That's awesome. But I'm a little bit worried by this right here:
const args = script.split(' ');
, it doesn't handle quoted arguments. If you give it something like thisYou would get.
Would
Deno.run
handle that?That's a great observation. Do you have any suggestions on how to handle this case?
I found this package: exec. It does the same thing as that function with more options. You could use that. It only handles double quotes but it's an improvement.
If anyone is curious how they do it, here it is.
What about double quotes enclosed within single quotes, echo 'And he said: "My name is!" ${name}'. It's a contrived example but you get the gist.
For that you would get.
See, the double quotes stayed, but everything else is broken. Having a bulletproof regex is a real pain. If you want to improve it, you have to modify this
var myRegexp = /[^\s"]+|"([^"]*)"/gi;
.