Files
5chan/electron/after-all-artifact-build.cjs
T

38 lines
1.4 KiB
JavaScript
Raw Normal View History

const fs = require('fs-extra');
const path = require('path');
const { execSync } = require('child_process');
const packageJson = require('../package.json');
const rootPath = path.resolve(__dirname, '..');
2023-04-24 19:42:49 +00:00
const distFolderPath = path.resolve(rootPath, 'dist');
function addPortableToPortableExecutableFileName() {
2023-04-24 19:42:49 +00:00
const files = fs.readdirSync(distFolderPath);
for (const file of files) {
if (file.endsWith('.exe') && !file.match('Setup')) {
const filePath = path.resolve(distFolderPath, file);
2023-12-16 16:49:26 +00:00
const renamedFilePath = path.resolve(distFolderPath, file.replace('plebchan', 'plebchan Portable'));
2023-04-24 19:42:49 +00:00
fs.moveSync(filePath, renamedFilePath);
}
}
}
2023-04-24 19:42:49 +00:00
function createHtmlArchive() {
2023-04-24 19:42:49 +00:00
if (process.platform !== 'linux') {
return;
}
const zipBinPath = path.resolve(rootPath, 'node_modules', '7zip-bin', 'linux', 'x64', '7za');
const plebchanHtmlFolderName = `plebchan-html-${packageJson.version}`;
2023-04-24 19:42:49 +00:00
const outputFile = path.resolve(distFolderPath, `${plebchanHtmlFolderName}.zip`);
const inputFolder = path.resolve(rootPath, 'build');
try {
execSync(`${zipBinPath} a ${outputFile} ${inputFolder}`);
execSync(`${zipBinPath} rn -r ${outputFile} build ${plebchanHtmlFolderName}`);
} catch (e) {
console.error('electron build createHtmlArchive error:', e);
2023-04-24 19:42:49 +00:00
}
}
2023-04-24 19:42:49 +00:00
module.exports = async function afterAllArtifactBuild(buildResult) {
2023-04-24 19:42:49 +00:00
addPortableToPortableExecutableFileName();
createHtmlArchive();
};