File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 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+ ``` json5
28+ {
29+ // Your other package.json stuff goes here...
30+ " scripts" : {
31+ " my-cool-script" : " echo 'sleep for 3 seconds' && shx sleep 3"
32+ }
33+ // ...
34+ }
35+ ```
36+
37+ And now you can run your package.json script:
38+
39+ ``` shell
40+ $ npm run my-cool-script
41+ ```
42+
43+ ** Important:** make sure you execute this via the ` npm run ` script, do not try
44+ to call ` shx ` directly from your terminal. If you call ` shx ` directly in the
45+ terminal, then ` shx ` won't be able to import the plugins from your local
46+ ` node_modules/ ` directory. Calling this via ` npm run ` script fixes the problem
47+ because ` npm ` automatically adds ` node_modules/ ` to the import path.
48+
49+ ** Note:** ` shx ` will only load plugins if a ` .shxrc.json ` file is present in the
50+ working directory, so it's recommended to add this JSON file to the top level of
51+ your project, right next to your project's package.json file.
Original file line number Diff line number Diff 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 ) |
You can’t perform that action at this time.
0 commit comments