[Poly > Yauzl] Minor source cleanup

This commit is contained in:
Ducko 2022-03-11 13:44:16 +00:00
parent 2ed61b67f6
commit 61d0f3a2ab
1 changed files with 5 additions and 6 deletions

View File

@ -1,10 +1,9 @@
// Jank replacement for yauzl by just using unzip where it expects and skipping (speed++, size--, jank++)
const { execFile } = require('child_process');
const { mkdirSync } = require('fs');
const { join, basename } = require('path');
const mkdirp = require('mkdirp');
exports.open = async (zipPath, _options, callback) => {
const extractPath = join(global.moduleDataPath, basename(zipPath).split('.')[0].split('-')[0]);
exports.open = async (zipPath, _opts, callback) => {
const extractPath = `${global.moduleDataPath}/${zipPath.split('/').pop().split('.')[0].split('-')[0])}`;
const listeners = [];
const errorOut = (err) => {
@ -21,9 +20,9 @@ exports.open = async (zipPath, _options, callback) => {
close: () => {}
});
mkdirSync(extractPath, { recursive: true });
mkdirp.sync(extractPath);
const proc = execFile('unzip', ['-q', '-o', zipPath.replaceAll('"', ''), '-d', extractPath]);
const proc = execFile('unzip', ['-q', '-o', zipPath, '-d', extractPath]);
proc.stderr.on('data', errorOut);