{"_id":"fallback-cli","_rev":"214812","name":"fallback-cli","description":"Default to the locally installed version of your CLI, use the global one if not found.","dist-tags":{"latest":"2.0.2"},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"}],"time":{"modified":"2021-06-03T15:34:26.000Z","created":"2015-09-27T18:57:22.707Z","2.0.2":"2015-10-04T17:02:53.693Z","2.0.1":"2015-10-04T04:38:30.743Z","2.0.0":"2015-10-04T03:58:31.543Z","1.0.4":"2015-10-03T21:34:18.723Z","1.0.3":"2015-09-28T21:40:21.146Z","1.0.2":"2015-09-28T21:11:00.904Z","1.0.1":"2015-09-28T20:57:53.721Z","1.0.0":"2015-09-28T20:56:18.187Z","0.0.1":"2015-09-27T18:57:22.707Z"},"users":{},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"repository":{"type":"git","url":"git+https://github.com/jamestalmage/fallback-cli.git"},"versions":{"2.0.2":{"name":"fallback-cli","version":"2.0.2","description":"Default to the locally installed version of your CLI, use the global one if not found.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jamestalmage/fallback-cli.git"},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"engines":{"node":">=0.10.0"},"scripts":{"test":"./test/clean-tests.sh && xo && mocha test/*-test.js && ./test/test.sh"},"files":["index.js","normalize-args.js","default-runner.js"],"keywords":["cli","fallback","global","local","default","command","script"],"dependencies":{"caller":"^1.0.0","resolve":"^1.1.6"},"devDependencies":{"mocha":"^2.2.5","xo":"^0.9.0"},"xo":{"envs":["node","mocha"]},"gitHead":"19825309a7c79aad00066ce2ebd0a6ecad8f094c","bugs":{"url":"https://github.com/jamestalmage/fallback-cli/issues"},"homepage":"https://github.com/jamestalmage/fallback-cli#readme","_id":"fallback-cli@2.0.2","_shasum":"546156e0214000ca2c22179d149958d3dacab5af","_from":".","_npmVersion":"2.14.2","_nodeVersion":"0.12.7","_npmUser":{"name":"jamestalmage","email":"james@talmage.io"},"dist":{"shasum":"546156e0214000ca2c22179d149958d3dacab5af","size":3876,"noattachment":false,"key":"/fallback-cli/-/fallback-cli-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/fallback-cli/download/fallback-cli-2.0.2.tgz"},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"}],"directories":{},"publish_time":1443978173693,"_cnpm_publish_time":1443978173693,"_hasShrinkwrap":false},"2.0.1":{"name":"fallback-cli","version":"2.0.1","description":"Default to the locally installed version of your CLI, use the global one if not found.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jamestalmage/fallback-cli.git"},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"engines":{"node":">=0.10.0"},"scripts":{"test":"./test/clean-tests.sh && xo && mocha test/*-test.js && ./test/test.sh"},"files":["index.js","normalize-args.js"],"keywords":["cli","fallback","global","local","default","command","script"],"dependencies":{"caller":"^1.0.0","resolve":"^1.1.6"},"devDependencies":{"mocha":"^2.2.5","xo":"^0.9.0"},"xo":{"envs":["node","mocha"]},"gitHead":"ecbac2caa08b109d030aaf1dd24123635b0a321e","bugs":{"url":"https://github.com/jamestalmage/fallback-cli/issues"},"homepage":"https://github.com/jamestalmage/fallback-cli#readme","_id":"fallback-cli@2.0.1","_shasum":"9025c25cef6e72278d1d594c0e332f961a646b6e","_from":".","_npmVersion":"2.14.2","_nodeVersion":"0.12.7","_npmUser":{"name":"jamestalmage","email":"james@talmage.io"},"dist":{"shasum":"9025c25cef6e72278d1d594c0e332f961a646b6e","size":3801,"noattachment":false,"key":"/fallback-cli/-/fallback-cli-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/fallback-cli/download/fallback-cli-2.0.1.tgz"},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"}],"directories":{},"publish_time":1443933510743,"_cnpm_publish_time":1443933510743,"deprecated":"error in package.json meant some files were not deployed to npm","_hasShrinkwrap":false},"2.0.0":{"name":"fallback-cli","version":"2.0.0","description":"Default to the locally installed version of your CLI, use the global one if not found.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jamestalmage/fallback-cli.git"},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"engines":{"node":">=0.10.0"},"scripts":{"test":"./test/clean-tests.sh && xo && mocha test/*-test.js && ./test/test.sh"},"files":["index.js","normalize-args.js"],"keywords":["cli","fallback","global","local","default","command","script"],"dependencies":{"caller":"^1.0.0","resolve":"^1.1.6"},"devDependencies":{"mocha":"^2.2.5","xo":"^0.9.0"},"xo":{"envs":["node","mocha"]},"gitHead":"18a974602f3c44b5c992ceea7c1e857576eccdf9","bugs":{"url":"https://github.com/jamestalmage/fallback-cli/issues"},"homepage":"https://github.com/jamestalmage/fallback-cli#readme","_id":"fallback-cli@2.0.0","_shasum":"165f98e95ecd933cb2c7b476037e5b401af1e935","_from":".","_npmVersion":"2.14.2","_nodeVersion":"0.12.7","_npmUser":{"name":"jamestalmage","email":"james@talmage.io"},"dist":{"shasum":"165f98e95ecd933cb2c7b476037e5b401af1e935","size":3627,"noattachment":false,"key":"/fallback-cli/-/fallback-cli-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/fallback-cli/download/fallback-cli-2.0.0.tgz"},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"}],"directories":{},"publish_time":1443931111543,"_cnpm_publish_time":1443931111543,"deprecated":"error in package.json meant some files were not deployed to npm","_hasShrinkwrap":false},"1.0.4":{"name":"fallback-cli","version":"1.0.4","description":"Default to the locally installed version of your CLI, use the global one if not found.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jamestalmage/fallback-cli.git"},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"engines":{"node":">=0.10.0"},"scripts":{"test":"./test/clean-tests.sh && xo && mocha test/*-test.js && ./test/test.sh"},"files":["index.js","normalize-args.js"],"keywords":["cli","fallback","global","local","default","command","script"],"dependencies":{"caller":"^1.0.0","resolve":"^1.1.6","run-async":"^0.1.0"},"devDependencies":{"mocha":"^2.2.5","xo":"^0.9.0"},"xo":{"envs":["node","mocha"]},"gitHead":"231adcc204e193d80f10d443fc62ab754ac55d8c","bugs":{"url":"https://github.com/jamestalmage/fallback-cli/issues"},"homepage":"https://github.com/jamestalmage/fallback-cli#readme","_id":"fallback-cli@1.0.4","_shasum":"098429ae834b08b4e38c91e65ea2dcf6b84f451a","_from":".","_npmVersion":"2.14.2","_nodeVersion":"0.12.7","_npmUser":{"name":"jamestalmage","email":"james@talmage.io"},"dist":{"shasum":"098429ae834b08b4e38c91e65ea2dcf6b84f451a","size":4140,"noattachment":false,"key":"/fallback-cli/-/fallback-cli-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/fallback-cli/download/fallback-cli-1.0.4.tgz"},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"}],"directories":{},"publish_time":1443908058723,"_cnpm_publish_time":1443908058723,"_hasShrinkwrap":false},"1.0.3":{"name":"fallback-cli","version":"1.0.3","description":"Default to the locally installed version of your CLI, use the global one if not found.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jamestalmage/fallback-cli.git"},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"engines":{"node":">=0.10.0"},"scripts":{"test":"./test/clean-tests.sh && xo && mocha test/*-test.js && ./test/test.sh"},"files":["index.js","normalize-args.js"],"keywords":["cli","fallback","global","local","default","command","script"],"dependencies":{"caller":"^1.0.0","resolve":"^1.1.6","run-async":"^0.1.0"},"devDependencies":{"mocha":"^2.2.5","xo":"^0.9.0"},"xo":{"envs":["node","mocha"]},"gitHead":"9841c10346351aae5aa6030aa8c6851d5440a737","bugs":{"url":"https://github.com/jamestalmage/fallback-cli/issues"},"homepage":"https://github.com/jamestalmage/fallback-cli#readme","_id":"fallback-cli@1.0.3","_shasum":"844ad4d83f8c45ab36b57c5e0e95a22de10696bd","_from":".","_npmVersion":"2.14.2","_nodeVersion":"0.12.7","_npmUser":{"name":"jamestalmage","email":"james@talmage.io"},"dist":{"shasum":"844ad4d83f8c45ab36b57c5e0e95a22de10696bd","size":4131,"noattachment":false,"key":"/fallback-cli/-/fallback-cli-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/fallback-cli/download/fallback-cli-1.0.3.tgz"},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"}],"directories":{},"publish_time":1443476421146,"_cnpm_publish_time":1443476421146,"_hasShrinkwrap":false},"1.0.2":{"name":"fallback-cli","version":"1.0.2","description":"Default to the locally installed version of your CLI, use the global one if not found.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jamestalmage/fallback-cli.git"},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"engines":{"node":">=0.10.0"},"scripts":{"test":"./test/clean-tests.sh && xo && mocha test/*-test.js && ./test/test.sh"},"files":["index.js","normalize-args.js"],"keywords":["cli","fallback","global","local","default","command","script"],"dependencies":{"caller":"^1.0.0","resolve":"^1.1.6","run-async":"^0.1.0"},"devDependencies":{"mocha":"^2.2.5","xo":"^0.9.0"},"xo":{"envs":["node","mocha"]},"gitHead":"0d909475e42ded83962fcbfa752e6fcc3a0da6b5","bugs":{"url":"https://github.com/jamestalmage/fallback-cli/issues"},"homepage":"https://github.com/jamestalmage/fallback-cli#readme","_id":"fallback-cli@1.0.2","_shasum":"8f7fee1d4178abc4261f830792da3b5a9593347f","_from":".","_npmVersion":"2.14.2","_nodeVersion":"0.12.7","_npmUser":{"name":"jamestalmage","email":"james@talmage.io"},"dist":{"shasum":"8f7fee1d4178abc4261f830792da3b5a9593347f","size":4099,"noattachment":false,"key":"/fallback-cli/-/fallback-cli-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/fallback-cli/download/fallback-cli-1.0.2.tgz"},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"}],"directories":{},"publish_time":1443474660904,"_cnpm_publish_time":1443474660904,"_hasShrinkwrap":false},"1.0.1":{"name":"fallback-cli","version":"1.0.1","description":"Default to the locally installed version of your CLI, use the global one if not found.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jamestalmage/fallback-cli.git"},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"engines":{"node":">=0.10.0"},"scripts":{"test":"./test/clean-tests.sh && xo && mocha test/*-test.js && ./test/test.sh"},"files":["index.js"],"keywords":["cli","fallback","global","local","default","command","script"],"dependencies":{"caller":"^1.0.0","resolve":"^1.1.6","run-async":"^0.1.0"},"devDependencies":{"mocha":"^2.2.5","xo":"^0.9.0"},"xo":{"envs":["node","mocha"]},"gitHead":"af99ddeee7070b3fe4a3be757f31b31724bb09ca","bugs":{"url":"https://github.com/jamestalmage/fallback-cli/issues"},"homepage":"https://github.com/jamestalmage/fallback-cli#readme","_id":"fallback-cli@1.0.1","_shasum":"92034d69b31a598d27bd816f9e4a02f9d3665f08","_from":".","_npmVersion":"2.14.2","_nodeVersion":"0.12.7","_npmUser":{"name":"jamestalmage","email":"james@talmage.io"},"dist":{"shasum":"92034d69b31a598d27bd816f9e4a02f9d3665f08","size":3776,"noattachment":false,"key":"/fallback-cli/-/fallback-cli-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/fallback-cli/download/fallback-cli-1.0.1.tgz"},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"}],"directories":{},"publish_time":1443473873721,"_cnpm_publish_time":1443473873721,"_hasShrinkwrap":false},"1.0.0":{"name":"fallback-cli","version":"1.0.0","description":"My well-made module","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jamestalmage/fallback-cli.git"},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"engines":{"node":">=0.10.0"},"scripts":{"test":"./test/clean-tests.sh && xo && mocha test/*-test.js && ./test/test.sh"},"files":["index.js"],"keywords":["cli","fallback","global","local","default","command","script"],"dependencies":{"caller":"^1.0.0","resolve":"^1.1.6","run-async":"^0.1.0"},"devDependencies":{"mocha":"^2.2.5","xo":"^0.9.0"},"xo":{"envs":["node","mocha"]},"gitHead":"2c28b77428eb9942a3d48c9d096de5541b02057c","bugs":{"url":"https://github.com/jamestalmage/fallback-cli/issues"},"homepage":"https://github.com/jamestalmage/fallback-cli#readme","_id":"fallback-cli@1.0.0","_shasum":"5770fe209a7bfe4e2ab5d5084785ad27b2a5ea28","_from":".","_npmVersion":"2.14.2","_nodeVersion":"0.12.7","_npmUser":{"name":"jamestalmage","email":"james@talmage.io"},"dist":{"shasum":"5770fe209a7bfe4e2ab5d5084785ad27b2a5ea28","size":3787,"noattachment":false,"key":"/fallback-cli/-/fallback-cli-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/fallback-cli/download/fallback-cli-1.0.0.tgz"},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"}],"directories":{},"publish_time":1443473778187,"_cnpm_publish_time":1443473778187,"_hasShrinkwrap":false},"0.0.1":{"name":"fallback-cli","version":"0.0.1","description":"My well-made module","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jamestalmage/fallback-cli.git"},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"engines":{"node":">=0.10.0"},"scripts":{"test":"./test/clean-tests.sh && xo && mocha test/*-test.js && ./test/test.sh"},"files":["index.js"],"keywords":[],"dependencies":{"caller":"^1.0.0","resolve":"^1.1.6","run-async":"^0.1.0"},"devDependencies":{"mocha":"^2.2.5","xo":"^0.9.0"},"xo":{"envs":["node","mocha"]},"gitHead":"bf7d4502d334d37071044822a23119088aa2d622","bugs":{"url":"https://github.com/jamestalmage/fallback-cli/issues"},"homepage":"https://github.com/jamestalmage/fallback-cli#readme","_id":"fallback-cli@0.0.1","_shasum":"7c251321e6a00d45557d882dc6a23207ea047ab3","_from":".","_npmVersion":"2.14.2","_nodeVersion":"0.12.7","_npmUser":{"name":"jamestalmage","email":"james@talmage.io"},"dist":{"shasum":"7c251321e6a00d45557d882dc6a23207ea047ab3","size":1835,"noattachment":false,"key":"/fallback-cli/-/fallback-cli-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/fallback-cli/download/fallback-cli-0.0.1.tgz"},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"}],"directories":{},"publish_time":1443380242707,"_cnpm_publish_time":1443380242707,"_hasShrinkwrap":false}},"readme":"# fallback-cli [![Build Status](https://travis-ci.org/jamestalmage/fallback-cli.svg?branch=master)](https://travis-ci.org/jamestalmage/fallback-cli)\n\n> Default to the locally installed version of your CLI, use the global one if not found.\n\nThis allows users to install your tool globally, but revert to whatever version is installed\nlocally in `node_modules`. `npm` already handles this when running scripts defined in `package.json`,\nbut this works even when invoking your CLI command directly from the console.\n\n## Install\n\n```\n$ npm install --save fallback-cli\n```\n\n## Usage\n\nThe following assumes you have a package named `my-module`, and the CLI script is `bin/cli.js`.\n\nFirst, create `cli-shim.js`, and place it in the *same directory* as your current CLI script.\n\n`bin/cli-shim.js`:\n\n```js\n#!/usr/bin/env node\nrequire('fallback-cli')('my-module/bin/cli.js');\n```\n\nNext update your `package.json` to point to `cli-shim.js`.\n\n```json\n{\n  \"name\": \"my-module\",\n  \"bin\": \"bin/cli-shim.js\"\n}\n```\n\n*That is it!* \n\nYour globally installed CLI will use the local version from `node_modules` if it exists.\nIn most cases this will even be compatible with old versions of your CLI before you introduced `fallback-cli`.\n\n**Note:** `cli.js` and `cli-shim.js` are arbitrary file names, use whatever you want.\n\n## API\n\n### fallbackCli(path, [relativePath], [customRunner])\n\nOnly `path` is required.\n\n  * `path`: *must* be a `string` describing your packages name, and the path to your CLI within the package (i.e. `my-module/bin/my-cli.js`).\n        \n  * `relativePath`: It is *highly recommended* that your \"shim\" to be installed in the same directory as the actual CLI. \nIf that is not possible, you *may* use `relativePath` to describe where it is relative to the shim.\n\n    ```js\n    fallbackCli('my-module/bin/the-cli.js', '../bin/the-cli.js');\n    ```\n    \n  If specified, `relativePath` *must* point to the same file as `path`.\n    \n  * `customRunner`: A callback that that will be invoked with a single `runnerOptions` object. It should launch your CLI implementation.\n  \n  The default runner is simple: \n  \n  ```js\n  function defaultRunner(runnerOptions) {\n    require(runnerOptions.cli);\n  }\n  ```\n  \n#### runnerOptions\n  \n  If you specify a `customRunner` function, it is passed an object with these properties:\n\n  * `localCli`: The absolute path of the CLI script in the locally installed module. It will be `null` if there is no local install.\n  \n  * `globalCli`: The absolute path of the CLI script in the globally installed module. It will be `null` if the locally installed script was invoked directly (i.e. via `npm run <script>`, or `./node_modules/.bin/my-cli`).\n  \n  * `localPkg`: The absolute path of `package.json` in the local module. Useful for determining the version of the local install. \n                It will be `null` if there is no local install, or in the very unlikely event `package.json` could not be found in the locally installed module.\n  \n  * `globalPkg`: The absolute path of `package.json` in the global module. Useful for determining the version of the global install. \n                 It will be `null` if the locally installed script was invoked directly, or if `package.json` could not be found in the globally installed module.\n                 \n  It is possible to confuse the algorithm that finds the global `package.json` if you do not put the shim in the same directory as the CLI script and use the `relativePath` argument.\n  For this reason, it is *highly recommended* you put them both in the same directory and avoid using `relativePath`. \n   \n  * `cli`: The same as `localCli` if found, otherwise falls back to be the same as `globalCli`. Convenience property for implementing a graceful fallback.\n  \n  * `pkg`: The same as `localPkg` if found, otherwise falls back to be the same as `globalPkg`.\n  \n  * `location`: Either `\"local\"` or `\"global\"` depending on which is found (`local` takes precedence).\n\n**Note:** All properties are of type `string`. All properties except `location` can also be `null`.\n\n## Alternate API\n\n### fallbackCli(options)\n\nAs an alternative to individual arguments, you can provide a single `options` argument.\n\n#### options.path\n\n**required**\n\nType: `string`\n\nSame as `path` described in `fallbackCli(path)` above.\n\n#### options.relative\n\n*optional*\n\nType: `string`\n\nSame as `relativePath` described in `fallbackCli(path, relativePath)` above.\n\n#### options.run\n\n*optional*\n\nType: `callback(runnerOptions)`\n\nSame as `customRunner` described in `fallbackCli(path, customRunner)` above.\n\n## License\n\nMIT © [James Talmage](http://github.com/jamestalmage)\n","_attachments":{},"homepage":"https://github.com/jamestalmage/fallback-cli#readme","bugs":{"url":"https://github.com/jamestalmage/fallback-cli/issues"},"license":"MIT"}