@@ -30,7 +30,7 @@ export {
30
30
* Modifies the package.json, sets config.commitizen.path to the path of the adapter
31
31
* Must be passed an absolute path to the cli's root
32
32
*/
33
- function addPathToAdapterConfig ( sh , cliPath , repoPath , adapterNpmName ) {
33
+ function addPathToAdapterConfig ( sh , cliPath , repoPath , adapterNpmName ) {
34
34
35
35
let commitizenAdapterConfig = {
36
36
config : {
@@ -46,7 +46,7 @@ function addPathToAdapterConfig(sh, cliPath, repoPath, adapterNpmName) {
46
46
let indent = detectIndent ( packageJsonString ) . indent || ' ' ;
47
47
let packageJsonContent = JSON . parse ( packageJsonString ) ;
48
48
let newPackageJsonContent = '' ;
49
- if ( _ . get ( packageJsonContent , 'config.commitizen.path' ) !== adapterNpmName ) {
49
+ if ( _ . get ( packageJsonContent , 'config.commitizen.path' ) !== adapterNpmName ) {
50
50
newPackageJsonContent = _ . merge ( packageJsonContent , commitizenAdapterConfig ) ;
51
51
}
52
52
fs . writeFileSync ( packageJsonPath , JSON . stringify ( newPackageJsonContent , null , indent ) + '\n' ) ;
@@ -55,14 +55,14 @@ function addPathToAdapterConfig(sh, cliPath, repoPath, adapterNpmName) {
55
55
/**
56
56
* Generates an npm install command given a map of strings and a package name
57
57
*/
58
- function generateNpmInstallAdapterCommand ( stringMappings , adapterNpmName ) {
58
+ function generateNpmInstallAdapterCommand ( stringMappings , adapterNpmName ) {
59
59
60
60
// Start with an initial npm install command
61
61
let installAdapterCommand = `npm install ${ adapterNpmName } ` ;
62
62
63
63
// Append the neccesary arguments to it based on user preferences
64
- for ( let [ key , value ] of stringMappings . entries ( ) ) {
65
- if ( value ) {
64
+ for ( let [ key , value ] of stringMappings . entries ( ) ) {
65
+ if ( value ) {
66
66
installAdapterCommand = installAdapterCommand + ' ' + value ;
67
67
}
68
68
}
@@ -73,15 +73,15 @@ function generateNpmInstallAdapterCommand(stringMappings, adapterNpmName) {
73
73
/**
74
74
* Gets the nearest npm_modules directory
75
75
*/
76
- function getNearestNodeModulesDirectory ( options ) {
76
+ function getNearestNodeModulesDirectory ( options ) {
77
77
78
78
// Get the nearest node_modules directories to the current working directory
79
79
let nodeModulesDirectories = findNodeModules ( options ) ;
80
80
81
81
// Make sure we find a node_modules folder
82
82
83
83
/* istanbul ignore else */
84
- if ( nodeModulesDirectories && nodeModulesDirectories . length > 0 ) {
84
+ if ( nodeModulesDirectories && nodeModulesDirectories . length > 0 ) {
85
85
return nodeModulesDirectories [ 0 ] ;
86
86
} else {
87
87
console . error ( `Error: Could not locate node_modules in your project's root directory. Did you forget to npm init or npm install?` )
@@ -91,33 +91,33 @@ function getNearestNodeModulesDirectory(options) {
91
91
/**
92
92
* Gets the nearest project root directory
93
93
*/
94
- function getNearestProjectRootDirectory ( options ) {
94
+ function getNearestProjectRootDirectory ( options ) {
95
95
return path . join ( process . cwd ( ) , getNearestNodeModulesDirectory ( options ) , '/../' ) ;
96
96
}
97
97
98
98
/**
99
99
* Gets a map of arguments where the value is the corresponding npm strings
100
100
*/
101
- function getNpmInstallStringMappings ( save , saveDev , saveExact , force ) {
101
+ function getNpmInstallStringMappings ( save , saveDev , saveExact , force ) {
102
102
return new Map ( )
103
- . set ( 'save' , ( save && ! saveDev ) ? '--save' : undefined )
104
- . set ( 'saveDev' , saveDev ? '--save-dev' : undefined )
105
- . set ( 'saveExact' , saveExact ? '--save-exact' : undefined )
106
- . set ( 'force' , force ? '--force' : undefined ) ;
103
+ . set ( 'save' , ( save && ! saveDev ) ? '--save' : undefined )
104
+ . set ( 'saveDev' , saveDev ? '--save-dev' : undefined )
105
+ . set ( 'saveExact' , saveExact ? '--save-exact' : undefined )
106
+ . set ( 'force' , force ? '--force' : undefined ) ;
107
107
}
108
108
109
109
/**
110
110
* Gets the prompter from an adapter given an adapter path
111
111
*/
112
- function getPrompter ( adapterPath ) {
112
+ function getPrompter ( adapterPath ) {
113
113
// Resolve the adapter path
114
114
let resolvedAdapterPath = resolveAdapterPath ( adapterPath ) ;
115
115
116
116
// Load the adapter
117
117
let adapter = require ( resolvedAdapterPath ) ;
118
118
119
119
/* istanbul ignore next */
120
- if ( adapter && adapter . prompter && isFunction ( adapter . prompter ) ) {
120
+ if ( adapter && adapter . prompter && isFunction ( adapter . prompter ) ) {
121
121
return adapter . prompter ;
122
122
} else if ( adapter && adapter . default && adapter . default . prompter && isFunction ( adapter . default . prompter ) ) {
123
123
return adapter . default . prompter ;
@@ -130,7 +130,7 @@ function getPrompter(adapterPath) {
130
130
* Given a resolvable module name or path, which can be a directory or file, will
131
131
* return a located adapter path or will throw.
132
132
*/
133
- function resolveAdapterPath ( inboundAdapterPath ) {
133
+ function resolveAdapterPath ( inboundAdapterPath ) {
134
134
// Check if inboundAdapterPath is a path or node module name
135
135
let parsed = path . parse ( inboundAdapterPath ) ;
136
136
let isPath = parsed . dir . length > 0 && parsed . dir . charAt ( 0 ) !== "@" ;
@@ -149,6 +149,6 @@ function resolveAdapterPath(inboundAdapterPath) {
149
149
}
150
150
}
151
151
152
- function getGitRootPath ( ) {
152
+ function getGitRootPath ( ) {
153
153
return sh . exec ( 'git rev-parse --show-toplevel' ) . stdout . trim ( ) ;
154
154
}
0 commit comments