Skip to content

Commit 7c97f09

Browse files
committed
docs: instructions for plugins
I realized that shelljs plugins actually are working correctly with the latest shx release, however it's somewhat tricky to set this up properly. I've documented the steps in a new markdown page. Fixes #239
1 parent 7c2dd8c commit 7c97f09

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

PLUGINS.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Plugin support
2+
3+
Did you know that `shx` can also take advantage of all the great
4+
[ShellJS plugins](https://www.npmjs.com/search?q=keyword%3Ashelljs%2Cplugin)?
5+
Here's how to get started using plugins with your project:
6+
7+
## Using plugins from inside package.json scripts
8+
9+
```shell
10+
$ npm install --save-dev shx
11+
$ npm install --save-dev shelljs-plugin-sleep
12+
```
13+
14+
Define a file named `.shxrc.json` to tell `shx` which plugins to load:
15+
16+
```json
17+
{
18+
"plugins": [
19+
"shelljs-plugin-sleep"
20+
]
21+
}
22+
```
23+
24+
Define a script in package.json which invokes the desired `shx` plugin as a
25+
command:
26+
27+
```json
28+
{
29+
"scripts": {
30+
"my-cool-script": "echo 'sleep for 3 seconds' && shx sleep 3"
31+
}
32+
}
33+
```
34+
35+
And now you can run your package.json script:
36+
37+
```shell
38+
$ npm run my-cool-script
39+
```
40+
41+
**Note:** `shx` will only load plugins if a `.shxrc.json` file is present in the
42+
working directly, so it's recommended to add this file to the top level of each
43+
project which needs to use the plugin.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ supported options:
153153
| N/A | N/A | `shx --help` | Show help text. |
154154
| N/A | N/A | `shx --version` | Print the shx version. |
155155

156+
### Plugin support
157+
158+
Did you know that `shx` can also take advantage of all the great
159+
[ShellJS plugins](https://www.npmjs.com/search?q=keyword%3Ashelljs%2Cplugin)?
160+
See [PLUGINS.md](./PLUGINS.md) for instructions.
161+
156162
## Team
157163

158164
| [![Nate Fischer](https://avatars.githubusercontent.com/u/5801521?s=130)](https://github.com/nfischer) | [![Ari Porad](https://avatars1.githubusercontent.com/u/1817508?v=3&s=130)](http://github.com/ariporad) | [![Levi Thomason](https://avatars1.githubusercontent.com/u/5067638?v=3&s=130)](https://github.com/levithomason) |

0 commit comments

Comments
 (0)