allow another module to manage scripts

(Maciej Krüger) #1

Background

Currently there exists a module called scripty. That module serves the purpose of running a shell script instead of adding large commands to the package.json. That way it stays clean and the bulky script files are easier to maintain due to being multi-line.

But to use this module one has to add every script individually into the scripts section, even though this module could do this part on it’s own.

Idea

Add a way to proxy/override the npm run behavior to simply pass the script name to another cli, without requireing an entry in the scripts section.

Implementation

Instead of adding scripts like this…

{
  "scripts": {
     "build": "scripty",
     "start": "scripty",
  }
}

…the whole section could be overridden with the command that handles script managment for this package

{
  "scripts": "scripty"
}

The invoked command could then read the name of the script that it is supposed to run based on the environment variables that npm would give to it. As those currently include the script name anyways, there would be no changes required for this to work.

0 Likes