[Scripts] Use scripts dir for containing util scripts
This commit is contained in:
parent
2a77d914c1
commit
888ed721c8
4 changed files with 7 additions and 5 deletions
18
scripts/injectPolyfills.js
Normal file
18
scripts/injectPolyfills.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
const { readdirSync, mkdirSync, copyFileSync } = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
const rootDir = join(__dirname, '..');
|
||||
|
||||
const polyfillsDir = join(rootDir, 'polyfills');
|
||||
for (const file of readdirSync(polyfillsDir)) {
|
||||
const [ name ] = file.split('.');
|
||||
const jsPath = join(polyfillsDir, file);
|
||||
|
||||
const moduleDir = join(rootDir, 'src', 'node_modules', name);
|
||||
|
||||
try {
|
||||
mkdirSync(moduleDir);
|
||||
} catch (e) {}
|
||||
|
||||
copyFileSync(jsPath, join(moduleDir, 'index.js'));
|
||||
}
|
14
scripts/strip.js
Normal file
14
scripts/strip.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
const { execSync } = require('child_process');
|
||||
const { readdirSync } = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
// Strip unneeded files in node deps
|
||||
execSync(`rm -rf src/package-lock.json src/node_modules/.package-lock.json src/node_modules/**/package.json src/node_modules/**/*.md src/node_modules/**/.*.yml src/node_modules/**/.npmignore src/node_modules/**/LICENSE src/node_modules/**/test*`);
|
||||
|
||||
// Minify node deps code
|
||||
|
||||
for (const package of readdirSync('src/node_modules')) {
|
||||
const indexPath = join('src/node_modules', package, 'index.js');
|
||||
|
||||
execSync(`npx uglifyjs --compress --mangle -o ${indexPath} -- ${indexPath}`);
|
||||
}
|
14
scripts/test.sh
Executable file
14
scripts/test.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "Packing asar..."
|
||||
node scripts/injectPolyfills.js
|
||||
asar pack src app.asar # Package asar
|
||||
# asar list app.asar # List asar for debugging / testing
|
||||
|
||||
echo "Copying asar..."
|
||||
cp app.asar /opt/discord-canary/resources/app.asar # Overwrite app.asar for Linux Canary
|
||||
|
||||
echo "Running discord..."
|
||||
echo ""
|
||||
|
||||
discord-canary # Run it
|
Loading…
Add table
Add a link
Reference in a new issue