UNPKG

4.47 kBMarkdownView Raw
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
13Requires [Node](https://nodejs.org/en/), but this is a shell script.
14
15```sh
16npm install --save-dev stop-only
17```
18
19## Use
20
21### basic
22
23Assuming 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
33Exits with 1 if there is ".only" somewhere in the files inside "specs" folder or inside "bin" folder.
34
35### warn
36
37If you just want to warn on found `.only`, use `stop-only --warn --folder <folder path>` syntax. Alias `-w`.
38
39### exclude folders
40
41If 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
53You 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
65You can search a single file using `--file` argument
66
67```text
68stop-only --file tests/spec.js
69```
70
71Or just warn
72
73```text
74stop-only --warn --file tests/spec.js
75```
76
77### Pre-commit or pre-push hook
78
79If 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
91See [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
99You can pass multiple folder names as separate arguments or comma-separated. These are equivalent
100
101```
102stop-only --folder foo --folder bar --skip src --skip source
103stop-only -f foo -f bar -s src -s source
104stop-only -f foo,bar -s src,source
105```
106
107### Debugging
108
109You can see additional diagnostic output from this command by running with environment variable `DEBUG=stop-only`
110
111### CI
112
113On 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
122Author: Gleb Bahmutov &lt;gleb.bahmutov@gmail.com&gt; &copy; 2017
123
124* [@bahmutov](https://twitter.com/bahmutov)
125* [glebbahmutov.com](https://glebbahmutov.com)
126* [blog](https://glebbahmutov.com/blog)
127
128License: MIT - do anything with the code, but don't blame me if it does not work.
129
130Support: 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
135Copyright (c) 2017 Gleb Bahmutov &lt;gleb.bahmutov@gmail.com&gt;
136
137Permission is hereby granted, free of charge, to any person
138obtaining a copy of this software and associated documentation
139files (the "Software"), to deal in the Software without
140restriction, including without limitation the rights to use,
141copy, modify, merge, publish, distribute, sublicense, and/or sell
142copies of the Software, and to permit persons to whom the
143Software is furnished to do so, subject to the following
144conditions:
145
146The above copyright notice and this permission notice shall be
147included in all copies or substantial portions of the Software.
148
149THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
150EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
151OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
152NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
153HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
154WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
155FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
156OTHER 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/