1 | # npm-quick-run
|
2 |
|
3 | > Quickly run NPM script by prefix without typing the full name
|
4 |
|
5 | [![NPM][npm-quick-run-icon] ][npm-quick-run-url]
|
6 |
|
7 | [![Build status][npm-quick-run-ci-image] ][npm-quick-run-ci-url]
|
8 | [![semantic-release][semantic-image] ][semantic-url]
|
9 | [![manpm](https://img.shields.io/badge/manpm-%E2%9C%93-3399ff.svg)](https://github.com/bahmutov/manpm)
|
10 |
|
11 | ## Install
|
12 |
|
13 | Install as a global tool `npm install -g npm-quick-run`. This creates two aliases `nrun` and `nr`
|
14 |
|
15 | ## Use example
|
16 |
|
17 | $ nr t # runs script starting with "t"
|
18 | $ nr m -w # runs a script starting with "m", probably "npm run mocha -- -w"
|
19 |
|
20 | ## Demo
|
21 |
|
22 | Watch this screencast to see `npm-quick-run` in action. I am using `nr` alias
|
23 |
|
24 | [![demo](https://asciinema.org/a/31015.png)](https://asciinema.org/a/31015)
|
25 |
|
26 | ## Details
|
27 |
|
28 | Take a look at the scripts inside your `package.json`. You probably have something like
|
29 | this
|
30 |
|
31 | ```json
|
32 | "scripts": {
|
33 | "test": "...",
|
34 | "lint": "..."
|
35 | }
|
36 | ```
|
37 |
|
38 | You can quickly run tests using `nr t` and run the linter using `nr l`, assuming there are
|
39 | no other script names starting with `t` or `l`. If there are, just be more specific and provide
|
40 | more unique prefix.
|
41 |
|
42 | ## Extra arguments
|
43 |
|
44 | You can pass extra arguments right after the prefix string
|
45 |
|
46 | nr t --watch
|
47 |
|
48 | would be the same as
|
49 |
|
50 | npm run test -- --watch
|
51 |
|
52 | which can run Mocha unit tests in the watching mode for example.
|
53 |
|
54 | ## Error handling
|
55 |
|
56 | If there are no scripts starting with the given prefix, an error message will be shown.
|
57 | If there are multiple scripts, they will be printed to the console and an error will be shown.
|
58 |
|
59 | ## Similar projects
|
60 |
|
61 | * [npm-run](https://www.npmjs.com/package/npm-run) run locally-installed executables to avoid
|
62 | using long string `node node_modules/.bin/some-alias ...`
|
63 | * [nrun](https://github.com/2do2go/nrun) is very similar to this project, but the script name
|
64 | completion is done via shell script, see [the relevant issue](https://github.com/2do2go/nrun/issues/3).
|
65 |
|
66 | ### Small print
|
67 |
|
68 | Author: Gleb Bahmutov © 2015
|
69 |
|
70 | * [@bahmutov](https://twitter.com/bahmutov)
|
71 | * [glebbahmutov.com](http://glebbahmutov.com)
|
72 | * [blog](http://glebbahmutov.com/blog/)
|
73 |
|
74 | License: MIT - do anything with the code, but don't blame me if it does not work.
|
75 |
|
76 | Spread the word: tweet, star on github, etc.
|
77 |
|
78 | Support: if you find any problems with this module, email / tweet /
|
79 | [open issue](https://github.com/bahmutov/npm-quick-run/issues) on Github
|
80 |
|
81 | ## MIT License
|
82 |
|
83 | Copyright (c) 2015 Gleb Bahmutov
|
84 |
|
85 | Permission is hereby granted, free of charge, to any person
|
86 | obtaining a copy of this software and associated documentation
|
87 | files (the "Software"), to deal in the Software without
|
88 | restriction, including without limitation the rights to use,
|
89 | copy, modify, merge, publish, distribute, sublicense, and/or sell
|
90 | copies of the Software, and to permit persons to whom the
|
91 | Software is furnished to do so, subject to the following
|
92 | conditions:
|
93 |
|
94 | The above copyright notice and this permission notice shall be
|
95 | included in all copies or substantial portions of the Software.
|
96 |
|
97 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
98 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
99 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
100 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
101 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
102 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
103 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
104 | OTHER DEALINGS IN THE SOFTWARE.
|
105 |
|
106 | [npm-quick-run-icon]: https://nodei.co/npm/npm-quick-run.png?downloads=true
|
107 | [npm-quick-run-url]: https://npmjs.org/package/npm-quick-run
|
108 | [npm-quick-run-ci-image]: https://travis-ci.org/bahmutov/npm-quick-run.png?branch=master
|
109 | [npm-quick-run-ci-url]: https://travis-ci.org/bahmutov/npm-quick-run
|
110 | [semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
|
111 | [semantic-url]: https://github.com/semantic-release/semantic-release
|