add support for packing source and compile in separate folders when packing script run ...
This commit is contained in:
@@ -15,6 +15,13 @@ async function handlePack() {
|
|||||||
var folderName = date.toDateString()
|
var folderName = date.toDateString()
|
||||||
.replace(" ", "");
|
.replace(" ", "");
|
||||||
|
|
||||||
|
//
|
||||||
|
const prjBasePath = XFileTools.joinPath(packsPath, folderName);
|
||||||
|
|
||||||
|
//
|
||||||
|
const prjBaseSourcePath = XFileTools.joinPath(prjBasePath, "Source");
|
||||||
|
const prjBaseCompiledPath = XFileTools.joinPath(prjBasePath, "Compile");
|
||||||
|
|
||||||
//
|
//
|
||||||
const isPacksExists = XFileTools.isDirectoryExists(packsPath);
|
const isPacksExists = XFileTools.isDirectoryExists(packsPath);
|
||||||
if (!isPacksExists) {
|
if (!isPacksExists) {
|
||||||
@@ -22,13 +29,22 @@ async function handlePack() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
const isProjectExists = XFileTools.isDirectoryExists(folderName);
|
const isProjectExists = XFileTools.isDirectoryExists(prjBasePath);
|
||||||
if (!isProjectExists) {
|
if (!isProjectExists) {
|
||||||
XFileTools.createDirectory(folderName);
|
XFileTools.createDirectory(prjBasePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
const prjBasePath = XFileTools.joinPath(packsPath, folderName);
|
const isPrjBaseSourcePathExists = XFileTools.isDirectoryExists(prjBaseSourcePath);
|
||||||
|
if (!isPrjBaseSourcePathExists) {
|
||||||
|
XFileTools.createDirectory(prjBaseSourcePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
const isPrjBaseCompiledPathExists = XFileTools.isDirectoryExists(prjBaseCompiledPath);
|
||||||
|
if (!isPrjBaseCompiledPathExists) {
|
||||||
|
XFileTools.createDirectory(prjBaseCompiledPath);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
var foldersPath = [
|
var foldersPath = [
|
||||||
@@ -43,18 +59,18 @@ async function handlePack() {
|
|||||||
for (const path of foldersPath) {
|
for (const path of foldersPath) {
|
||||||
//
|
//
|
||||||
const fSourcePath = XFileTools.joinPath(".", path);
|
const fSourcePath = XFileTools.joinPath(".", path);
|
||||||
const fDestPath = XFileTools.joinPath(prjBasePath, path);
|
|
||||||
|
//
|
||||||
|
// Copy Sources ...
|
||||||
|
const sourceFilesToCopy = await XFileTools.extractFiles(fSourcePath, [".mq5", ".mq4"]);
|
||||||
|
if (sourceFilesToCopy && sourceFilesToCopy.length > 0) {
|
||||||
|
//
|
||||||
|
const fDestPath = XFileTools.joinPath(prjBaseSourcePath, path);
|
||||||
XFileTools.createDirectory(fDestPath);
|
XFileTools.createDirectory(fDestPath);
|
||||||
|
|
||||||
//
|
|
||||||
const filesToCopy = await XFileTools.extractFiles(fSourcePath, [".ex5", ".ex4"]);
|
|
||||||
if (!filesToCopy || filesToCopy.length == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Loop through Files ...
|
// Loop through Files ...
|
||||||
for (const f of filesToCopy) {
|
for (const f of sourceFilesToCopy) {
|
||||||
//
|
//
|
||||||
// Prepare Destination Path ...
|
// Prepare Destination Path ...
|
||||||
|
|
||||||
@@ -83,4 +99,45 @@ async function handlePack() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Compiled ...
|
||||||
|
const compiledFilesToCopy = await XFileTools.extractFiles(fSourcePath, [".ex5", ".ex4"]);
|
||||||
|
if (compiledFilesToCopy && compiledFilesToCopy.length > 0) {
|
||||||
|
//
|
||||||
|
const fDestPath = XFileTools.joinPath(prjBaseCompiledPath, path);
|
||||||
|
XFileTools.createDirectory(fDestPath);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Loop through Files ...
|
||||||
|
for (const f of compiledFilesToCopy) {
|
||||||
|
//
|
||||||
|
// Prepare Destination Path ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Log ...
|
||||||
|
console.log(
|
||||||
|
XColorTools.applyForegroundColor("try to copy: ", XColorTools.COLOR_NAMES.Yellow),
|
||||||
|
XColorTools.applyForegroundColor(f, XColorTools.COLOR_NAMES.Blue),
|
||||||
|
XColorTools.applyForegroundColor(" to : ", XColorTools.COLOR_NAMES.Yellow),
|
||||||
|
XColorTools.applyForegroundColor(fDestPath, XColorTools.COLOR_NAMES.Magenta)
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
let result = await XFileTools.copyFile(f, fDestPath);
|
||||||
|
if (result) {
|
||||||
|
//
|
||||||
|
const msg = "copy successfully ...";
|
||||||
|
console.log(
|
||||||
|
XColorTools.applyForegroundColor(msg, XColorTools.COLOR_NAMES.Green)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
const msg = "copy failed ...";
|
||||||
|
console.log(XColorTools.applyForegroundColor(msg, XColorTools.COLOR_NAMES.Red));
|
||||||
|
throw msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user