https://github.com/exogen/npm-extends
Don’t use this.
https://github.com/exogen/npm-extends
Last synced: 4 months ago
JSON representation
Don’t use this.
- Host: GitHub
- URL: https://github.com/exogen/npm-extends
- Owner: exogen
- License: mit
- Created: 2018-08-17T03:23:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-17T03:49:30.000Z (over 7 years ago)
- Last Synced: 2025-04-03T11:15:42.369Z (9 months ago)
- Language: JavaScript
- Size: 30.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# npm-extends 😈
## What?
This abuses npm’s `onload-script` option, which can be set on a per-project
basis, to poison the `require.cache` entry for npm’s `run-script` command with a
cooler version that runs a custom CLI of your choosing if the specified script
isn’t in `package.json`.
## Should I use this?
No.
## But how would I use it, in theory?
Install `npm-extends` in your project, then add an `.npmrc` file to your project
with this line:
```
onload-script="${PWD}/node_modules/npm-extends"
```
(Yes, unfortunately this will not work when you run `npm` from directories below
your `package.json`. You could probably make it work by installing `npm-extends`
globally.)
Add an `npm:extends` script to `scripts` in your `package.json` file that runs
the command you’d like to use instead of `npm run` when a script isn’t found.
It will be passed the script name and arguments.
```json
{
"scripts": {
"npm:extends": "your-cli",
"boring-script": "echo This is boring!"
}
}
```
Now you can run scripts that aren’t in there, but are supported by your tool!
```console
$ npm run boring-script
> echo BooOoOOOriing
BooOoOOOriing
$ npm run cool-script
> your-cli "cool-script"
WaaAAaay cooler!
```