@@ -30,15 +30,15 @@ export {
30
30
* Must be passed an absolute path to the cli's root
31
31
*/
32
32
function addPathToAdapterConfig ( sh , cliPath , repoPath , adapterNpmName ) {
33
-
33
+
34
34
let commitizenAdapterConfig = {
35
35
config : {
36
36
commitizen : {
37
37
path : `./node_modules/${ adapterNpmName } `
38
38
}
39
39
}
40
40
} ;
41
-
41
+
42
42
let packageJsonPath = path . join ( getNearestProjectRootDirectory ( ) , 'package.json' ) ;
43
43
let packageJsonString = fs . readFileSync ( packageJsonPath , 'utf-8' ) ;
44
44
// tries to detect the indentation and falls back to a default if it can't
@@ -55,28 +55,28 @@ function addPathToAdapterConfig(sh, cliPath, repoPath, adapterNpmName) {
55
55
* Generates an npm install command given a map of strings and a package name
56
56
*/
57
57
function generateNpmInstallAdapterCommand ( stringMappings , adapterNpmName ) {
58
-
58
+
59
59
// Start with an initial npm install command
60
60
let installAdapterCommand = `npm install ${ adapterNpmName } ` ;
61
-
61
+
62
62
// Append the neccesary arguments to it based on user preferences
63
63
for ( let [ key , value ] of stringMappings . entries ( ) ) {
64
64
if ( value ) {
65
65
installAdapterCommand = installAdapterCommand + ' ' + value ;
66
66
}
67
67
}
68
-
68
+
69
69
return installAdapterCommand ;
70
70
}
71
71
72
72
/**
73
73
* Gets the nearest npm_modules directory
74
74
*/
75
75
function getNearestNodeModulesDirectory ( options ) {
76
-
76
+
77
77
// Get the nearest node_modules directories to the current working directory
78
78
let nodeModulesDirectories = findNodeModules ( options ) ;
79
-
79
+
80
80
// Make sure we find a node_modules folder
81
81
if ( nodeModulesDirectories && nodeModulesDirectories . length > 0 ) {
82
82
return nodeModulesDirectories [ 0 ] ;
@@ -112,7 +112,7 @@ function getPrompter(adapterPath) {
112
112
113
113
// Load the adapter
114
114
let adapter = require ( resolvedAdapterPath ) ;
115
-
115
+
116
116
if ( adapter && adapter . prompter && isFunction ( adapter . prompter ) ) {
117
117
return adapter . prompter ;
118
118
} else {
@@ -128,12 +128,12 @@ function resolveAdapterPath(inboundAdapterPath) {
128
128
// Check if inboundAdapterPath is a path or node module name
129
129
let parsed = path . parse ( inboundAdapterPath ) ;
130
130
let isPath = parsed . dir . length > 0 ;
131
-
131
+
132
132
// Resolve from process.cwd() if inboundAdapterPath is a path
133
133
let absoluteAdapterPath = isPath ?
134
- path . resolve ( process . cwd ( ) , inboundAdapterPath ) :
134
+ path . resolve ( getNearestProjectRootDirectory ( ) , inboundAdapterPath ) :
135
135
inboundAdapterPath ;
136
-
136
+
137
137
try {
138
138
// try to resolve the given path
139
139
return require . resolve ( absoluteAdapterPath ) ;
0 commit comments