0.3.0 • Published 7 years ago

runwith v0.3.0

Weekly downloads
8
License
MIT
Repository
github
Last release
7 years ago

runwith

Travis Build Status AppVeyor Build Status Dependency Status devDependency Status

Dynamically requires module and calls it with a given arguments

Install

npm install --save-dev runwith

Usage

Use runwith in development as part of the npm scripts of from a command line. Another usage is not recommended.

λ runwith --help
Usage:
  runwith [options] [<module>] [arguments]

Options:
  --help  # Print the module options and usage

  --prop  # Path to module's object property to be called

Arguments:
  module  # Module name
          Alphanumeric names are treated as modules from `node_modules`
          Names with dots and slashes are treated as relative paths
  name    # Space separated list of arguments that will be passed module

Global

If runwith is installed globally, you can run it from your terminal in the following way:

runwith ./scripts/clean.js true

Local

When runwith is installed locally, you can use it in your npm scripts.

Let's imagine you have the following structure of the project:

+-- foo/
| |-- bar.js
| `-- baz.js
+-- index.js
`-- package.json

bar.js

module.exports = function callable(a, b) {
  // some code...
}

baz.js

module.exports = {
  quux: {
    quuux: function quuux( a ) { /* ... */ }
  }
}

package.json

{
  "name": "awesome-module",
  "version": "0.0.1",
  "scripts": {
    "bar": "runwith ./foo/bar someText 0",
    "baz": "runwith --prop=quux.quuux ./foo/bar 1",
  }
}

Afterwards, just run the bar script from terminal:

> npm run bar

Note: To access the nested property in the module's object, lodash.get is used.

License

MIT © Mikita Taukachou

0.3.0

7 years ago

0.2.0

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago