Fix requires
This commit is contained in:
parent
ac0c472be9
commit
05e53641c1
|
@ -3,13 +3,13 @@
|
||||||
const util = require('node:util');
|
const util = require('node:util');
|
||||||
const exec = util.promisify(require('node:child_process').exec);
|
const exec = util.promisify(require('node:child_process').exec);
|
||||||
|
|
||||||
const { platform, bin } = require('..');
|
const { getPlatform, getBin } = require('../include');
|
||||||
|
|
||||||
|
|
||||||
const actionZip = async () => {
|
const actionZip = async () => {
|
||||||
try {
|
try {
|
||||||
await exec(`cd ${bin} && tar -acf ../${platform}.zip *`);
|
await exec(`cd ${getBin()} && tar -acf ../${getPlatform()}.zip *`);
|
||||||
console.log(`zip=${platform}.zip`);
|
console.log(`zip=${getPlatform()}.zip`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
process.exit(-1);
|
process.exit(-1);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { copy, exists, mkdir, rm } = require('./files');
|
const { copy, exists, mkdir, rm } = require('./files');
|
||||||
const { bin } = require('..');
|
const { getBin } = require('../include');
|
||||||
|
|
||||||
|
|
||||||
const cpbin = async (name) => {
|
const cpbin = async (name) => {
|
||||||
|
@ -11,7 +11,7 @@ const cpbin = async (name) => {
|
||||||
console.error(`Error. File "${srcDir}/build/Release/${name}.node" not found.`);
|
console.error(`Error. File "${srcDir}/build/Release/${name}.node" not found.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const binAbs = `${srcDir}/../${bin}`;
|
const binAbs = `${srcDir}/../${getBin()}`;
|
||||||
|
|
||||||
if (!await exists(binAbs)) {
|
if (!await exists(binAbs)) {
|
||||||
await mkdir(binAbs);
|
await mkdir(binAbs);
|
||||||
|
@ -25,7 +25,7 @@ const cpbin = async (name) => {
|
||||||
|
|
||||||
await copy(`${srcDir}/build/Release/${name}.node`, destAbs);
|
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 };
|
module.exports = { cpbin };
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('node:fs');
|
||||||
const https = require('node:https');
|
const https = require('node:https');
|
||||||
const http = require('node:http');
|
const http = require('node:http');
|
||||||
const util = require('node:util');
|
const util = require('node:util');
|
||||||
const exec = util.promisify(require('node:child_process').exec);
|
const exec = util.promisify(require('node:child_process').exec);
|
||||||
|
|
||||||
const { bin, platform } = require('..');
|
const { getBin, getPlatform } = require('../include');
|
||||||
const { mkdir, rmdir, rm } = require('./files');
|
const { mkdir, rmdir, rm } = require('./files');
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +17,6 @@ const onError = (msg) => {
|
||||||
process.exit(-1);
|
process.exit(-1);
|
||||||
};
|
};
|
||||||
|
|
||||||
const zipPath = `${bin}/${bin}.zip`;
|
|
||||||
|
|
||||||
|
|
||||||
const installRecursive = async (url, count = 1) => {
|
const installRecursive = async (url, count = 1) => {
|
||||||
|
@ -44,10 +44,19 @@ const installRecursive = async (url, count = 1) => {
|
||||||
throw new Error(`Response status was ${response.statusCode}`);
|
throw new Error(`Response status was ${response.statusCode}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await rmdir(bin);
|
await rmdir(getBin());
|
||||||
await mkdir(bin);
|
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);
|
await rm(zipPath);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
@ -57,7 +66,7 @@ const installRecursive = async (url, count = 1) => {
|
||||||
|
|
||||||
|
|
||||||
const install = (folder) => {
|
const install = (folder) => {
|
||||||
const url = `${folder}/${platform}.zip`;
|
const url = `${folder}/${getPlatform()}.zip`;
|
||||||
installRecursive(url).then();
|
installRecursive(url).then();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue