Fix requires

This commit is contained in:
Luis Blanco 2023-01-04 13:22:46 +04:00
parent ac0c472be9
commit 05e53641c1
3 changed files with 21 additions and 12 deletions

View File

@ -3,13 +3,13 @@
const util = require('node:util');
const exec = util.promisify(require('node:child_process').exec);
const { platform, bin } = require('..');
const { getPlatform, getBin } = require('../include');
const actionZip = async () => {
try {
await exec(`cd ${bin} && tar -acf ../${platform}.zip *`);
console.log(`zip=${platform}.zip`);
await exec(`cd ${getBin()} && tar -acf ../${getPlatform()}.zip *`);
console.log(`zip=${getPlatform()}.zip`);
} catch (error) {
console.error(error);
process.exit(-1);

View File

@ -1,7 +1,7 @@
'use strict';
const { copy, exists, mkdir, rm } = require('./files');
const { bin } = require('..');
const { getBin } = require('../include');
const cpbin = async (name) => {
@ -11,7 +11,7 @@ const cpbin = async (name) => {
console.error(`Error. File "${srcDir}/build/Release/${name}.node" not found.`);
}
const binAbs = `${srcDir}/../${bin}`;
const binAbs = `${srcDir}/../${getBin()}`;
if (!await exists(binAbs)) {
await mkdir(binAbs);
@ -25,7 +25,7 @@ const cpbin = async (name) => {
await copy(`${srcDir}/build/Release/${name}.node`, destAbs);
console.log(`The binary "${name}.node" was copied to "${bin}".`);
console.log(`The binary "${name}.node" was copied to "${getBin()}".`);
};
module.exports = { cpbin };

View File

@ -1,11 +1,12 @@
'use strict';
const fs = require('node:fs');
const https = require('node:https');
const http = require('node:http');
const util = require('node:util');
const exec = util.promisify(require('node:child_process').exec);
const { bin, platform } = require('..');
const { getBin, getPlatform } = require('../include');
const { mkdir, rmdir, rm } = require('./files');
@ -16,7 +17,6 @@ const onError = (msg) => {
process.exit(-1);
};
const zipPath = `${bin}/${bin}.zip`;
const installRecursive = async (url, count = 1) => {
@ -44,10 +44,19 @@ const installRecursive = async (url, count = 1) => {
throw new Error(`Response status was ${response.statusCode}`);
}
await rmdir(bin);
await mkdir(bin);
await rmdir(getBin());
await mkdir(getBin());
await exec(`tar -xzvf ${platform}.zip --directory ${bin}`);
const zipPath = `${getBin()}/${getPlatform()}.zip`;
await new Promise((res, rej) => {
const zipWriter = fs.createWriteStream(zipPath);
zipWriter.on('error', (err) => rej(err));
zipWriter.on('finish', () => res());
response.pipe(zipWriter);
});
await exec(`tar -xzvf ${zipPath} --directory ${getBin()}`);
await rm(zipPath);
} catch (ex) {
@ -57,7 +66,7 @@ const installRecursive = async (url, count = 1) => {
const install = (folder) => {
const url = `${folder}/${platform}.zip`;
const url = `${folder}/${getPlatform()}.zip`;
installRecursive(url).then();
};