Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions scripts/build.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,36 @@ const zipDirectory = path.resolve(builtinDirectory, `${package.name}.cdix`);
const extFiles = path.resolve(__dirname, '../.extfiles');
const fileStream = fs.createReadStream(extFiles, { encoding: 'utf8' });

/** @type {string | undefined} */
let urlProtocol;
const argv = process.argv.slice(2);
for (let i = 0; i < argv.length; i++) {
if (argv[i] === '--url-protocol') {
const next = argv[i + 1];
if (next !== undefined && !next.startsWith('--')) {
urlProtocol = next;
i++;
}
}
}

const includedFiles = [];
const excludedFiles = [];

function applyUrlProtocolToSuccessHtml() {
if (urlProtocol === undefined || urlProtocol === '') {
return;
}
const successHtmlPath = path.join(zipDirectory, 'www/success.html');
if (!fs.existsSync(successHtmlPath)) {
console.error(`Error: file not found: ${successHtmlPath}`);
process.exit(1);
}
const content = fs.readFileSync(successHtmlPath, 'utf8');
const updated = content.replaceAll('podman-desktop', urlProtocol);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it odd that this is ctrl+f ctrl+r podman-desktop through it?

fs.writeFileSync(successHtmlPath, updated, 'utf8');
}

// remove the .cdix file before zipping
if (fs.existsSync(destFile)) {
fs.rmSync(destFile);
Expand Down Expand Up @@ -74,6 +101,7 @@ cproc.exec('pnpm init', { cwd: './dist' }, (error, stdout, stderr) => {
if (error) {
throw new Error('Error copying files', error);
}
applyUrlProtocolToSuccessHtml();
console.log(`Zipping files to ${destFile}`);
const zip = new AdmZip();
zip.addLocalFolder(zipDirectory);
Expand Down