Commit 906822ad authored by 李金钢's avatar 李金钢

Add new file

parent 90e2d913
const fs = require('fs');
const path = require('path');
const { exec } = require('child_process');
// Define source and destination paths
const dest = "E:/CPAS6-101 UFCPAS6.0 致同智审IAS版_测试版";
const src = "G:/cpas-framework/release/win-unpacked";
// Function to execute shell commands
function execCommand(command) {
return new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if (error) {
reject(`Error: ${stderr}`);
} else {
resolve(stdout);
}
});
});
}
// Recursive function to copy files and directories
function copyFiles(src, dest) {
return new Promise((resolve, reject) => {
fs.readdir(src, (err, files) => {
if (err) {
reject(`Error reading source directory: ${err}`);
}
let promises = [];
files.forEach(file => {
const srcPath = path.join(src, file);
const destPath = path.join(dest, file);
promises.push(new Promise((resolve, reject) => {
fs.stat(srcPath, (err, stats) => {
if (err) {
reject(`Error getting file stats: ${err}`);
} else {
if (stats.isDirectory()) {
// Create directory and copy files inside it
fs.mkdir(destPath, { recursive: true }, (err) => {
if (err) reject(`Error creating directory: ${err}`);
else {
// Recursively copy directory contents
copyFiles(srcPath, destPath).then(resolve).catch(reject);
}
});
} else {
// Copy file
fs.copyFile(srcPath, destPath, fs.constants.COPYFILE_FICLONE, (err) => {
if (err) reject(`Error copying file: ${err}`);
else resolve();
});
}
}
});
}));
});
// Wait for all file operations to complete
Promise.all(promises)
.then(resolve)
.catch(reject);
});
});
}
// Start process
async function main() {
try {
console.log(`Source path: ${src}`);
console.log(`Destination path: ${dest}`);
// Create destination directory if it doesn't exist
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, { recursive: true });
}
// Copy files from source to destination (recursive)
console.log("Starting file copy...");
await copyFiles(src, dest);
console.log("File copy completed.");
// Run the updateVersion.js script using Node
console.log("Running updateVersion.js...");
await execCommand(`node "${dest}/buildscript/updateVersion.js"`);
console.log("updateVersion.js completed.");
// Run ISCC to compile the installer
console.log("Running ISCC.exe...");
await execCommand(`ISCC.exe "${dest}/CPAS6Setup_智审IAS作业平台.iss"`);
console.log("ISCC.exe completed.");
console.log("Script execution completed successfully.");
} catch (error) {
console.error("An error occurred:", error);
}
}
// Execute the main function
main();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment