Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcusoftnet/scradd
Adds script to a package.json file from the terminal or in scripts
https://github.com/marcusoftnet/scradd
Last synced: about 5 hours ago
JSON representation
Adds script to a package.json file from the terminal or in scripts
- Host: GitHub
- URL: https://github.com/marcusoftnet/scradd
- Owner: marcusoftnet
- License: mit
- Created: 2021-06-17T09:58:58.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-03T09:36:24.000Z (about 2 years ago)
- Last Synced: 2024-10-31T17:15:00.721Z (15 days ago)
- Language: JavaScript
- Size: 30.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
- License: LICENSE
Awesome Lists containing this project
README
# ScrAdd - Script Adder
Adds script to a package.json file from the terminal or in scripts.
I've often seen the need to programmatically be able to add a script or two to a `package.json`, for example when writing instructions for a tutorial or lesson. With ScrAdd this is now just a `npx` command away.
ScrAdd will not overwrite existing scripts, but rather inform you that one of those exists already.
## Usage
```bash
npx scradd {path to package.json} {script name} {script content} -o'
```* `-o` - overwrites an existing script. Default behavior is to not overwrite existing scripts
## Examples
* Add a simple script to a local `package.json`
```bash
npx scradd . test "mocha ."
```* Add a simple script to a non-local `package.json`
```bash
npx scradd ~/projects/myproj/package.json test "mocha ."
```* Adding a script with separators in the name requires quotes:
```bash
npx scradd . "test:watch:integration" "mocha ."
```* Adding script content just about always requires quotes, since it contains spaces:
```bash
npx scradd . "test:watch" "npm t -- -R min -w ./src/"
```* Overwrite an existing script using the `-o` flag, for example the `test` script that is created by default:
```bash
npx scradd . "test" "mocha -R min" -o
```## Contribute
This is a quick and dirty first version of the code. I wanted it to be workable but not perfect.
You can contribute to this package by forking the repository and clone it to your computer. Remember to add tests.