@@ -175,22 +175,33 @@ export default class Base_Java {
175
175
* @returns {string|undefined }
176
176
*/
177
177
traverseForWrapper ( startingManifest , repoRoot = undefined ) {
178
- repoRoot = repoRoot || getGitRootDir ( path . resolve ( path . dirname ( startingManifest ) ) ) || path . parse ( path . resolve ( startingManifest ) ) . root
179
-
180
- const wrapperName = this . localWrapper ;
181
- const wrapperPath = path . join ( path . resolve ( path . dirname ( startingManifest ) ) , wrapperName ) ;
178
+ const normalizedManifest = this . normalizePath ( startingManifest ) ;
179
+ const currentDir = this . normalizePath ( path . dirname ( normalizedManifest ) ) ;
180
+ repoRoot = repoRoot || getGitRootDir ( currentDir ) || path . parse ( normalizedManifest ) . root ;
181
+ const wrapperPath = path . join ( currentDir , this . localWrapper ) ;
182
182
183
183
try {
184
- fs . accessSync ( wrapperPath , fs . constants . X_OK )
185
- } catch ( error ) {
184
+ fs . accessSync ( wrapperPath , fs . constants . X_OK ) ;
185
+ return wrapperPath ;
186
+ }
187
+ catch ( error ) {
186
188
if ( error . code === 'ENOENT' ) {
187
- if ( path . resolve ( path . dirname ( startingManifest ) ) === repoRoot ) {
188
- return undefined
189
+ const rootDir = path . parse ( currentDir ) . root ;
190
+ if ( currentDir === repoRoot || currentDir === rootDir ) {
191
+ return undefined ;
192
+ }
193
+ const parentDir = path . dirname ( currentDir ) ;
194
+ if ( parentDir === currentDir || parentDir === rootDir ) {
195
+ return undefined ;
189
196
}
190
- return this . traverseForWrapper ( path . resolve ( path . dirname ( startingManifest ) ) , repoRoot )
197
+ return this . traverseForWrapper ( path . join ( parentDir , path . basename ( normalizedManifest ) ) , repoRoot ) ;
191
198
}
192
- throw new Error ( `failure searching for ${ this . localWrapper } ` , { cause : error } )
199
+ throw new Error ( `failure searching for ${ this . localWrapper } ` , { cause : error } ) ;
193
200
}
194
- return wrapperPath
201
+ }
202
+
203
+ normalizePath ( thePath ) {
204
+ const normalized = path . resolve ( thePath ) . normalize ( ) ;
205
+ return process . platform === 'win32' ? normalized . toLowerCase ( ) : normalized ;
195
206
}
196
207
}
0 commit comments