update core.lib

This commit is contained in:
linyuchen
2024-04-29 20:32:39 +08:00
parent 0aecd7ac2f
commit 2de0acc9b6
48 changed files with 165 additions and 46 deletions

View File

@@ -0,0 +1,19 @@
import * as os from 'os';
import path from 'node:path';
import fs from 'fs';
export function getModuleWithArchName(moduleName: string) {
const systemPlatform = os.platform;
const cpuArch = os.arch;
return `${moduleName}-${systemPlatform}-${cpuArch}.node`;
}
export function cpModule(moduleName: string) {
const currentDir = path.resolve(__dirname);
const fileName = `./${getModuleWithArchName(moduleName)}`;
try {
fs.copyFileSync(path.join(currentDir, fileName), path.join(currentDir, `${moduleName}.node`));
} catch (e) {
}
}