From d5b8bc587770e4a7efd6a36962abaa0425931181 Mon Sep 17 00:00:00 2001 From: Sergio Gomez Date: Sun, 17 Jun 2018 22:12:42 -0500 Subject: [PATCH] docs(readme): add npx use examples (#532) closes #502 --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8bf0cd2b..d290edf0 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,18 @@ npm install -g commitizen #### Using the command line tool Now, simply use `git cz` instead of `git commit` when committing. +_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: +``` +npx git-cz +``` +or as an npm script: +```json + ... + "scripts": { + "commit": "npx git-cz" + } +``` + 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. [![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 Install Commitizen with `npm install --save-dev commitizen`. -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. +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: +``` +npx commitizen init cz-conventional-changelog --save-dev --save-exact +``` + +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. You can then initialize the conventional changelog adapter using: `./node_modules/.bin/commitizen init cz-conventional-changelog --save-dev --save-exact`