Commit 999e6c5d97246e80be3475a0418e31ab178cf9c3
Handle dylib native modules
cel committed on 5/11/2020, 4:08:12 PMParent: 65191f9a9664f013ebe726bb95a1a54b086e1bd5
Files changed
prelude/bootstrap.js | changed |
prelude/bootstrap.js | |||
---|---|---|---|
@@ -1600,9 +1600,9 @@ | |||
1600 | 1600 … | } | |
1601 | 1601 … | args[1] = tmpModulePath; | |
1602 | 1602 … | } | |
1603 | 1603 … | ||
1604 | - const unknownModuleErrorRegex = /([^:]+): cannot open shared object file: No such file or directory/; | ||
1604 … | + const unknownModuleErrorRegex = /([^:]+): cannot open shared object file: No such file or directory|Library not loaded: @loader_path\/(\S+)/; | ||
1605 | 1605 … | const tryImporting = function (previousErrorMessage) { | |
1606 | 1606 … | try { | |
1607 | 1607 … | const res = ancestor.dlopen.apply(process, args); | |
1608 | 1608 … | return res; | |
@@ -1614,9 +1614,10 @@ | |||
1614 | 1614 … | if (e.message.match(unknownModuleErrorRegex)) { | |
1615 | 1615 … | // some modules are packaged with dynamic linking and needs to open other files that should be in | |
1616 | 1616 … | // the same directory, in this case, we write this file in the same /tmp directory and try to | |
1617 | 1617 … | // import the module again | |
1618 | - const moduleName = e.message.match(unknownModuleErrorRegex)[1]; | ||
1618 … | + const m = e.message.match(unknownModuleErrorRegex) | ||
1619 … | + const moduleName = m[1] || m[2]; | ||
1619 | 1620 … | const modulePath = `${moduleDirname}/${moduleName}`; | |
1620 | 1621 … | const moduleContent = fs.readFileSync(modulePath); | |
1621 | 1622 … | const moduleBaseName = require('path').basename(modulePath); | |
1622 | 1623 … | const tmpModulePath = `${require('os').tmpdir()}/${moduleBaseName}`; |
Built with git-ssb-web