MCPcopy Index your code
hub / github.com/commitizen/cz-cli / bootstrap

Function bootstrap

src/cli/commitizen.js:14–86  ·  view source on GitHub ↗

* This is the main cli entry point. * environment may be used for debugging.

(environment = {}, argv = process.argv)

Source from the content-addressed store, hash-verified

12 * environment may be used for debugging.
13 */
14function bootstrap (environment = {}, argv = process.argv) {
15
16 // Get cli args
17 let rawGitArgs = argv.slice(2, argv.length);
18
19 // Parse the args
20 let parsedArgs = parse(rawGitArgs);
21 let command = parsedArgs._[0];
22
23 // Do actions based on commands
24 if (command === "init") {
25 let adapterNpmName = parsedArgs._[1];
26 if (adapterNpmName) {
27 console.log(`Attempting to initialize using the npm package ${adapterNpmName}`);
28 try {
29 init(process.cwd(), adapterNpmName, parsedArgs);
30 } catch (e) {
31 console.error(`Error: ${e}`);
32 }
33 } else {
34 console.error('Error: You must provide an adapter name as the second argument.');
35 }
36 } else {
37 console.log(`
38
39 Commitizen has two command line tools:
40
41 1) cz -- used for making commits according to convention
42 note: you can run 'git cz' if installed with -g
43 2) git-cz -- alias for 'cz'
44 3) commitizen -- used for installing adapters into your project
45
46 Generally if you're using someone else's repo and they've already set up an
47 adapter, you're going to just be running:
48
49 cz
50
51 However, if you create a new repo and you want to make it easier for future
52 contributors to follow your commit message conventions using commitizen then
53 you'll need to run a command like this one to add this adapter to your config:
54
55 commitizen init cz-conventional-changelog --save
56
57 You should swap out cz-conventional-changelog for the NPM package name of the
58 adapter you wish you install in your project's package.json.
59
60 Detailed usage:
61
62 1) commitizen <sub-command>
63
64 init <adapter-npm-name> [args]
65
66 description: Install a commitizen adapter from npm and adds it to your
67 config.commitizen in your package.json file.
68
69 args:
70 --save Install the adapter to package.json dependencies
71 --save-dev Install the adapter to devDependencies

Callers

nothing calls this directly

Calls 2

initFunction · 0.90
parseFunction · 0.50

Tested by

no test coverage detected