fix(rust-binary-locator): use import.meta.resolve and url.fileURLToPath to locate bundled Rust binary in ESM environments
This commit is contained in:
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartrust',
|
||||
version: '1.1.1',
|
||||
version: '1.1.2',
|
||||
description: 'a bridge between JS engines and rust'
|
||||
}
|
||||
|
||||
@@ -108,7 +108,8 @@ export class RustBinaryLocator {
|
||||
const packageName = `${platformPackagePrefix}-${platform}-${arch}`;
|
||||
|
||||
try {
|
||||
const packagePath = require.resolve(`${packageName}/${binaryName}`);
|
||||
const resolved = import.meta.resolve(`${packageName}/${binaryName}`);
|
||||
const packagePath = plugins.url.fileURLToPath(resolved);
|
||||
if (await this.isExecutable(packagePath)) {
|
||||
return packagePath;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@ import * as fs from 'fs';
|
||||
import * as childProcess from 'child_process';
|
||||
import * as readline from 'readline';
|
||||
import * as events from 'events';
|
||||
import * as url from 'url';
|
||||
|
||||
export { path, fs, childProcess, readline, events };
|
||||
export { path, fs, childProcess, readline, events, url };
|
||||
|
||||
// @push.rocks scope
|
||||
import * as smartpath from '@push.rocks/smartpath';
|
||||
|
||||
Reference in New Issue
Block a user