style: Add semicolons and improve code formatting

- Add missing semicolons to all statements in prebuild.js
- Adjust indentation and spacing for consistency
- Remove trailing whitespace at end of file
This commit is contained in:
bobo.yang 2024-12-02 14:38:39 +08:00
parent 8ffad3b7db
commit 32f078bac2

View File

@ -1,26 +1,26 @@
require('dotenv').config()
require('dotenv').config();
const fs = require('fs')
const path = require('path')
const fs = require('fs');
const path = require('path');
function copyIcon(src, dst) {
if (!src) {
console.warn(`Icon path for ${dst} is not defined in your environment variables`)
return
console.warn(`Icon path for ${dst} is not defined in your environment variables`);
return;
}
console.log(`Replacing icon ${dst} by ${src}`)
console.log(`Replacing icon ${dst} by ${src}`);
if (!fs.existsSync(src)) {
console.warn(`Icon file ${src} does not exist.`)
return
console.warn(`Icon file ${src} does not exist.`);
return;
}
const destPath = path.join(__dirname, 'assets', dst)
const destPath = path.join(__dirname, 'assets', dst);
try {
fs.copyFileSync(src, destPath)
fs.chmodSync(destPath, 0o644)
fs.copyFileSync(src, destPath);
fs.chmodSync(destPath, 0o644);
} catch(e) {
console.warn(`Failed to copy logo ${e}`)
console.warn(`Failed to copy logo ${e}`);
}
}
@ -31,7 +31,7 @@ function updatePackageJson() {
ASSISTANT_NAME_EN: process.env.ASSISTANT_NAME_EN || "DevChat",
ASSISTANT_NAME_ZH: process.env.ASSISTANT_NAME_ZH || "DevChat"
}
console.log(`Updating package.json, env: ${JSON.stringify(placeholders)}`)
console.log(`Updating package.json, env: ${JSON.stringify(placeholders)}`);
let packageJson = fs.readFileSync('package.json', 'utf8');
@ -44,8 +44,8 @@ function updatePackageJson() {
fs.writeFileSync('package.json', packageJson);
}
copyIcon(process.env.EXTENSION_ICON, 'devchat.png')
copyIcon(process.env.SIDEBAR_ICON, 'devchat_icon.svg')
copyIcon(process.env.DIFF_APPLY_ICON, 'devchat_apply.svg')
copyIcon(process.env.EXTENSION_ICON, 'devchat.png');
copyIcon(process.env.SIDEBAR_ICON, 'devchat_icon.svg');
copyIcon(process.env.DIFF_APPLY_ICON, 'devchat_apply.svg');
updatePackageJson()
updatePackageJson();