1 | # stop-only
|
2 |
|
3 | > Detects '.only' left in the code accidentally. Works with "describe", "context" and "it".
|
4 |
|
5 | [![NPM][npm-icon] ][npm-url]
|
6 |
|
7 | [![Build status][ci-image] ][ci-url]
|
8 | [![semantic-release][semantic-image] ][semantic-url]
|
9 | [![renovate-app badge][renovate-badge]][renovate-app]
|
10 |
|
11 | ## Install
|
12 |
|
13 | Requires [Node](https://nodejs.org/en/), but this is a shell script.
|
14 |
|
15 | ```sh
|
16 | npm install --save-dev stop-only
|
17 | ```
|
18 |
|
19 | ## Use
|
20 |
|
21 | ### basic
|
22 |
|
23 | Assuming the tests are in the folder "specs", I recommend create an NPM run script. Use `--folder` or `-f` to pass the folder(s) to search.
|
24 |
|
25 | ```json
|
26 | {
|
27 | "scripts": {
|
28 | "stop-only": "stop-only --folder specs --folder bin"
|
29 | }
|
30 | }
|
31 | ```
|
32 |
|
33 | Exits with 1 if there is ".only" somewhere in the files inside "specs" folder or inside "bin" folder.
|
34 |
|
35 | ### warn
|
36 |
|
37 | If you just want to warn on found `.only`, use `stop-only --warn --folder <folder path>` syntax. Alias `-w`.
|
38 |
|
39 | ### exclude folders
|
40 |
|
41 | If you need to exclude certain folders, use `--skip` or `-s` option.
|
42 |
|
43 | ```json
|
44 | {
|
45 | "scripts": {
|
46 | "stop-only": "stop-only --folder specs --skip node_modules"
|
47 | }
|
48 | }
|
49 | ```
|
50 |
|
51 | ### exclude files
|
52 |
|
53 | You can exclude files by name using `--exclude` or `-e` option.
|
54 |
|
55 | ```json
|
56 | {
|
57 | "scripts": {
|
58 | "stop-only": "stop-only --folder specs --exclude foo-spec.js"
|
59 | }
|
60 | }
|
61 | ```
|
62 |
|
63 | ### searching file
|
64 |
|
65 | You can search a single file using `--file` argument
|
66 |
|
67 | ```text
|
68 | stop-only --file tests/spec.js
|
69 | ```
|
70 |
|
71 | Or just warn
|
72 |
|
73 | ```text
|
74 | stop-only --warn --file tests/spec.js
|
75 | ```
|
76 |
|
77 | ### Pre-commit or pre-push hook
|
78 |
|
79 | If using [pre-git][pre-git] to configure Git hooks, run this tool as a command
|
80 |
|
81 | ```json
|
82 | {
|
83 | "config": {
|
84 | "pre-git": {
|
85 | "pre-push": ["npm run stop-only"]
|
86 | }
|
87 | }
|
88 | }
|
89 | ```
|
90 |
|
91 | See [package.json](package.json) (note here we have just local script name).
|
92 |
|
93 | **tip** you can warn on commit hook, while fail in pre-push hook.
|
94 |
|
95 | [pre-git]: https://github.com/bahmutov/pre-git#readme
|
96 |
|
97 | ### Commas
|
98 |
|
99 | You can pass multiple folder names as separate arguments or comma-separated. These are equivalent
|
100 |
|
101 | ```
|
102 | stop-only --folder foo --folder bar --skip src --skip source
|
103 | stop-only -f foo -f bar -s src -s source
|
104 | stop-only -f foo,bar -s src,source
|
105 | ```
|
106 |
|
107 | ### Debugging
|
108 |
|
109 | You can see additional diagnostic output from this command by running with environment variable `DEBUG=stop-only`
|
110 |
|
111 | ### CI
|
112 |
|
113 | On CI run the tool after install, for example see [.travis.yml](.travis.yml),
|
114 | (note here we have just local script name).
|
115 |
|
116 | ```
|
117 | - npm run stop-only
|
118 | ```
|
119 |
|
120 | ### Small print
|
121 |
|
122 | Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2017
|
123 |
|
124 | * [@bahmutov](https://twitter.com/bahmutov)
|
125 | * [glebbahmutov.com](https://glebbahmutov.com)
|
126 | * [blog](https://glebbahmutov.com/blog)
|
127 |
|
128 | License: MIT - do anything with the code, but don't blame me if it does not work.
|
129 |
|
130 | Support: if you find any problems with this module, email / tweet /
|
131 | [open issue](https://github.com/bahmutov/stop-only/issues) on Github
|
132 |
|
133 | ## MIT License
|
134 |
|
135 | Copyright (c) 2017 Gleb Bahmutov <gleb.bahmutov@gmail.com>
|
136 |
|
137 | Permission is hereby granted, free of charge, to any person
|
138 | obtaining a copy of this software and associated documentation
|
139 | files (the "Software"), to deal in the Software without
|
140 | restriction, including without limitation the rights to use,
|
141 | copy, modify, merge, publish, distribute, sublicense, and/or sell
|
142 | copies of the Software, and to permit persons to whom the
|
143 | Software is furnished to do so, subject to the following
|
144 | conditions:
|
145 |
|
146 | The above copyright notice and this permission notice shall be
|
147 | included in all copies or substantial portions of the Software.
|
148 |
|
149 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
150 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
151 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
152 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
153 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
154 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
155 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
156 | OTHER DEALINGS IN THE SOFTWARE.
|
157 |
|
158 | [npm-icon]: https://nodei.co/npm/stop-only.svg?downloads=true
|
159 | [npm-url]: https://npmjs.org/package/stop-only
|
160 | [ci-image]: https://travis-ci.org/bahmutov/stop-only.svg?branch=master
|
161 | [ci-url]: https://travis-ci.org/bahmutov/stop-only
|
162 | [semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
|
163 | [semantic-url]: https://github.com/semantic-release/semantic-release
|
164 | [renovate-badge]: https://img.shields.io/badge/renovate-app-blue.svg
|
165 | [renovate-app]: https://renovateapp.com/
|