DEV Community

Discussion on: A simple way to replace npm scripts in Deno

Collapse
 
09wattry profile image
Ryan

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.

async function exec(script: String): Promise<any> {
  const args = script.split(' ');
  const proc = await Deno.run({ cmd: args }).status();

  if(proc.success == false) {
    Deno.exit(proc.code);
  }

  return proc;
}

export default exec;