Commit 5140bb8f authored by Auto Backup's avatar Auto Backup

build

parent 394f041c
......@@ -8,6 +8,7 @@ const DEFAULT_SRC = "G:/cpas-framework/release/win-unpacked";
// Default subfolders list to copy (empty array means copy all folders)
const DEFAULT_SUB_FOLDERS = [];
const PUBLISH_DIR= 'E:/产品安装包/05 大客户专版/109 致同/CPAS6.0 IAS版'
// Parse command line arguments
function parseArgs() {
const args = process.argv.slice(2);
......@@ -16,7 +17,7 @@ function parseArgs() {
src: DEFAULT_SRC,
subFolders: [...DEFAULT_SUB_FOLDERS]
};
for (let i = 0; i < args.length; i++) {
const arg = args[i];
if (arg === '--dest' && i + 1 < args.length) {
......@@ -28,7 +29,7 @@ function parseArgs() {
params.subFolders = args[++i].split(',').map(f => f.trim()).filter(f => f);
}
}
return params;
}
......@@ -53,23 +54,23 @@ function copyFiles(src, dest, subFolders = [], rootSrc = src) {
reject(`Error reading source directory: ${err}`);
return;
}
let promises = [];
files.forEach(file => {
const srcPath = path.join(src, file);
const destPath = path.join(dest, file);
// Check if it's a direct child of the root source directory
const relativePath = path.relative(rootSrc, srcPath);
const isDirectChild = relativePath === file && !relativePath.includes(path.sep);
promises.push(new Promise((resolve, reject) => {
fs.stat(srcPath, (err, stats) => {
if (err) {
reject(`Error getting file stats: ${err}`);
return;
}
if (stats.isDirectory()) {
// If it's a directory, check if filtering is needed
if (isDirectChild && subFolders.length > 0 && !subFolders.includes(file)) {
......@@ -78,7 +79,7 @@ function copyFiles(src, dest, subFolders = [], rootSrc = src) {
resolve();
return;
}
// Create directory and copy internal files
fs.mkdir(destPath, { recursive: true }, (err) => {
if (err) {
......@@ -115,7 +116,7 @@ async function main() {
try {
// Parse command line arguments
const { src, dest, subFolders } = parseArgs();
console.log(`Source path: ${src}`);
console.log(`Destination path: ${dest}`);
if (subFolders.length > 0) {
......@@ -132,7 +133,7 @@ async function main() {
// Copy files from source to destination (recursive)
console.log("Starting file copy...");
await copyFiles(src, dest, subFolders);
const iss= '/CPAS6Setup_IASWithBom.iss'
// If it's a file, copy directly
fs.copyFile("."+iss, dest, fs.constants.COPYFILE_FICLONE, (err) => {
......@@ -151,7 +152,8 @@ async function main() {
await execCommand(`D:/InnoSetup6/ISCC.exe "${dest}${iss}"`);
console.log("ISCC.exe completed.");
console.log("Script execution completed successfully.");
console.log("Script execution completed successfully.");
await copyFiles(src, PUBLISH_DIR, ['resources']);
} catch (error) {
console.error("An error occurred:", error);
}
......
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