[Poly > Yauzl] Initial Add
This commit is contained in:
parent
88c8a7bc27
commit
b3ffacf472
3 changed files with 49 additions and 11 deletions
8
.github/workflows/release_nightly.yml
vendored
8
.github/workflows/release_nightly.yml
vendored
|
@ -23,15 +23,9 @@ jobs:
|
|||
with:
|
||||
node-version: 16.x
|
||||
|
||||
- name: NPM Install
|
||||
run: |
|
||||
cd src
|
||||
npm i
|
||||
cd ..
|
||||
npm i -g asar uglify-js
|
||||
|
||||
- name: Pack base asar
|
||||
run: |
|
||||
npm i -g asar uglify-js
|
||||
node scripts/strip.js
|
||||
node scripts/injectPolyfills.js
|
||||
sed -i -e "s/nightly/nightly-$(git rev-parse HEAD | cut -c 1-7)/" src/index.js
|
||||
|
|
47
polyfills/yauzl.js
Normal file
47
polyfills/yauzl.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
// Jank replacement for yauzl by just using unzip where it expects and skipping (speed++, size--)
|
||||
const { spawn } = require('child_process');
|
||||
const { createReadStream, mkdirSync, rmdirSync } = require('original-fs');
|
||||
const { join, basename } = require('path');
|
||||
|
||||
exports.open = async (zipPath, _options, callback) => {
|
||||
const extractPath = join(global.moduleDataPath, basename(zipPath).split('.')[0].split('-')[0]);
|
||||
const listeners = [];
|
||||
log('Yauzl', 'Zip path:', zipPath, 'Extract path:', extractPath);
|
||||
|
||||
const errorOut = (err) => {
|
||||
listeners.error(err);
|
||||
};
|
||||
|
||||
callback(null, {
|
||||
on: (event, listener) => {
|
||||
listeners[event] = listener;
|
||||
},
|
||||
|
||||
readEntry: () => {},
|
||||
openReadStream: () => {},
|
||||
close: () => {}
|
||||
});
|
||||
|
||||
mkdirSync(extractPath, { recursive: true });
|
||||
|
||||
// const proc = spawn('tar', ['-v', '-xf', `"${zipPath.replaceAll('"', '')}"`, '-C', `"${extractPath}"`]);
|
||||
const proc = spawn('unzip', ['-o', `${zipPath.replaceAll('"', '')}`, '-d', `${extractPath}`]);
|
||||
console.log('spawn');
|
||||
proc.stdout.on('data', (data) => {
|
||||
});
|
||||
|
||||
proc.stderr.on('data', (data) => {
|
||||
console.log('stderr', data.toString());
|
||||
errorOut(data.toString());
|
||||
});
|
||||
|
||||
proc.on('error', (err) => {
|
||||
errorOut(err);
|
||||
});
|
||||
|
||||
proc.on('close', async () => {
|
||||
finishedExtract = true;
|
||||
console.log('close');
|
||||
listeners.end();
|
||||
});
|
||||
};
|
|
@ -1,8 +1,5 @@
|
|||
{
|
||||
"name": "discord",
|
||||
"description": "Open-source alternative of Discord desktop's app.asar",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"yauzl": "^2.10.0"
|
||||
}
|
||||
"main": "index.js"
|
||||
}
|
Loading…
Reference in a new issue