Did you know that shx can also take advantage of all the great
ShellJS plugins?
Here's how to get started using plugins with your project:
$ npm install --save-dev shx
$ npm install --save-dev shelljs-plugin-sleepDefine a file named .shxrc.json to tell shx which plugins to load:
{
"plugins": [
"shelljs-plugin-sleep"
]
}Define a script in package.json which invokes the desired shx plugin as a
command:
{
// Your other package.json stuff goes here...
"scripts": {
"my-cool-script": "echo 'sleep for 3 seconds' && shx sleep 3"
}
// ...
}And now you can run your package.json script:
$ npm run my-cool-scriptImportant: make sure you execute this via the npm run script, do not try
to call shx directly from your terminal. If you call shx directly in the
terminal, then shx won't be able to import the plugins from your local
node_modules/ directory. Calling this via npm run script fixes the problem
because npm automatically adds node_modules/ to the import path.
Note: shx will only load plugins if a .shxrc.json file is present in the
working directory, so it's recommended to add this JSON file to the top level of
your project, right next to your project's package.json file.