Skip to content

Commit d5b8bc5

Browse files
giocodesjimthedev
authored andcommitted
docs(readme): add npx use examples (#532)
closes #502
1 parent d103b10 commit d5b8bc5

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ npm install -g commitizen
1414
#### Using the command line tool
1515
Now, simply use `git cz` instead of `git commit` when committing.
1616

17+
_Alternatively_, if you are using **NPM 5.2+** you can [use `npx`](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) instead of installing globally:
18+
```
19+
npx git-cz
20+
```
21+
or as an npm script:
22+
```json
23+
...
24+
"scripts": {
25+
"commit": "npx git-cz"
26+
}
27+
```
28+
1729
When you're working in a Commitizen friendly repository, you'll be prompted to fill in any required fields and your commit messages will be formatted according to the standards defined by project maintainers.
1830

1931
[![Add and commit with Commitizen](https://github.com/commitizen/cz-cli/raw/master/meta/screenshots/add-commit.png)](https://github.com/commitizen/cz-cli/raw/master/meta/screenshots/add-commit.png)
@@ -101,7 +113,12 @@ Installing and running Commitizen locally allows you to make sure that developer
101113

102114
Install Commitizen with `npm install --save-dev commitizen`.
103115

104-
Once you have Commitizen installed as a local dev dependency you can execute `./node_modules/.bin/commitizen` or `./node_modules/.bin/git-cz` in order to actually use the commands.
116+
On **NPM 5.2+** you can [use `npx`](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) to initialize the conventional changelog adapter:
117+
```
118+
npx commitizen init cz-conventional-changelog --save-dev --save-exact
119+
```
120+
121+
For **previous versions of NPM (< 5.2) ** you can execute `./node_modules/.bin/commitizen` or `./node_modules/.bin/git-cz` in order to actually use the commands.
105122

106123
You can then initialize the conventional changelog adapter using: `./node_modules/.bin/commitizen init cz-conventional-changelog --save-dev --save-exact`
107124

0 commit comments

Comments
 (0)