-
-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(packager): fix resolving of afterCopy and afterExtract hook paths
- Loading branch information
1 parent
23d1aa9
commit bd4df68
Showing
2 changed files
with
13 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
import debug from 'debug'; | ||
import path from 'path'; | ||
|
||
const d = debug('electron-forge:require-search'); | ||
|
||
export default (relativeTo, paths) => { | ||
const testPaths = paths | ||
.concat(paths.map(mapPath => path.resolve(relativeTo, mapPath))) | ||
.concat(paths.map(mapPath => path.resolve(relativeTo, 'node_modules', mapPath))); | ||
d('searching', testPaths, 'relative to', relativeTo); | ||
let result; | ||
for (const testPath of paths.concat(paths.map(mapPath => path.resolve(relativeTo, mapPath)))) { | ||
for (const testPath of testPaths) { | ||
try { | ||
d('testing', testPath); | ||
result = require(testPath); | ||
return typeof result === 'object' && result && result.default ? result.default : result; | ||
} catch (err) { | ||
// Ignore the error | ||
} | ||
} | ||
d('failed to find a module in', testPaths); | ||
}; |