UNPKG

3.94 kBMarkdownView Raw
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
13Install 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
22Watch 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
28Take a look at the scripts inside your `package.json`. You probably have something like
29this
30
31```json
32"scripts": {
33 "test": "...",
34 "lint": "..."
35}
36```
37
38You can quickly run tests using `nr t` and run the linter using `nr l`, assuming there are
39no other script names starting with `t` or `l`. If there are, just be more specific and provide
40more unique prefix.
41
42## Extra arguments
43
44You can pass extra arguments right after the prefix string
45
46 nr t --watch
47
48would be the same as
49
50 npm run test -- --watch
51
52which can run Mocha unit tests in the watching mode for example.
53
54## Error handling
55
56If there are no scripts starting with the given prefix, an error message will be shown.
57If 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
68Author: Gleb Bahmutov © 2015
69
70* [@bahmutov](https://twitter.com/bahmutov)
71* [glebbahmutov.com](http://glebbahmutov.com)
72* [blog](http://glebbahmutov.com/blog/)
73
74License: MIT - do anything with the code, but don't blame me if it does not work.
75
76Spread the word: tweet, star on github, etc.
77
78Support: 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
83Copyright (c) 2015 Gleb Bahmutov
84
85Permission is hereby granted, free of charge, to any person
86obtaining a copy of this software and associated documentation
87files (the "Software"), to deal in the Software without
88restriction, including without limitation the rights to use,
89copy, modify, merge, publish, distribute, sublicense, and/or sell
90copies of the Software, and to permit persons to whom the
91Software is furnished to do so, subject to the following
92conditions:
93
94The above copyright notice and this permission notice shall be
95included in all copies or substantial portions of the Software.
96
97THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
98EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
99OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
100NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
101HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
102WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
103FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
104OTHER 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