prepare pack.js for packing robot ...
This commit is contained in:
@@ -349,7 +349,7 @@ function getFileExtension(path = '') {
|
||||
* @returns {Promise<string[]>}
|
||||
*/
|
||||
async function getRecursiveFilesList(
|
||||
path = "",
|
||||
path = "",
|
||||
extensions = []
|
||||
) {
|
||||
//
|
||||
@@ -366,7 +366,7 @@ async function getRecursiveFilesList(
|
||||
|
||||
//
|
||||
const contents = await getDirectoryContents(path);
|
||||
for(const item of contents) {
|
||||
for (const item of contents) {
|
||||
//
|
||||
const itemPath = joinPath(
|
||||
path,
|
||||
@@ -378,11 +378,11 @@ async function getRecursiveFilesList(
|
||||
if (isItemFile) {
|
||||
//
|
||||
const itemFileExtension = getFileExtension(itemPath);
|
||||
const isFileInSupportedExtensions =
|
||||
extensions === undefined || extensions.length === 0
|
||||
? true
|
||||
: extensions.includes(itemFileExtension)
|
||||
;
|
||||
const isFileInSupportedExtensions =
|
||||
extensions === undefined || extensions.length === 0
|
||||
? true
|
||||
: extensions.includes(itemFileExtension)
|
||||
;
|
||||
if (isFileInSupportedExtensions) {
|
||||
result.push(itemPath);
|
||||
}
|
||||
@@ -396,6 +396,65 @@ async function getRecursiveFilesList(
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract Specific files from a folder and it's content ...
|
||||
*
|
||||
* @param {string} path Folder Path ...
|
||||
* @returns
|
||||
*/
|
||||
async function extractFiles(path = "", ext = []) {
|
||||
//
|
||||
const result = [];
|
||||
|
||||
//
|
||||
if (!ext || ext.length == 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
const pathContent = await getDirectoryContents(path);
|
||||
if (!pathContent || pathContent.length == 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Loop through Content ...
|
||||
for (const c of pathContent) {
|
||||
//
|
||||
// Prepare full path ...
|
||||
const cPath = joinPath(path, c);
|
||||
|
||||
//
|
||||
// check content path is file or not ...
|
||||
const isCFile = isFileExists(cPath);
|
||||
const isCDirectory = isDirectoryExists(cPath);
|
||||
if (isCFile) {
|
||||
//
|
||||
// Check it is MQL file or not ...
|
||||
const cExt = getFileExtension(cPath);
|
||||
if (ext.includes(cExt)) {
|
||||
result.push(cPath);
|
||||
}
|
||||
} else if (isCDirectory) {
|
||||
//
|
||||
const destFolderName = basename(cPath);
|
||||
const isExcluded = excludeWorkspaceFolders.includes(destFolderName);
|
||||
if (isExcluded) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
const cFiles = await extractFiles(cPath, ext);
|
||||
if (cFiles && cFiles.length > 0) {
|
||||
result.push(...cFiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//
|
||||
@@ -770,8 +829,8 @@ async function writeJSON(
|
||||
|
||||
//
|
||||
result = await writeFile(
|
||||
path,
|
||||
contentString,
|
||||
path,
|
||||
contentString,
|
||||
true
|
||||
);
|
||||
|
||||
@@ -814,6 +873,7 @@ module.exports = {
|
||||
getFileExtension,
|
||||
removeFileExtension,
|
||||
getRecursiveFilesList,
|
||||
extractFiles,
|
||||
|
||||
//
|
||||
copyFolder,
|
||||
@@ -826,5 +886,5 @@ module.exports = {
|
||||
getDirectoryFiles,
|
||||
getDirectoryFolders,
|
||||
getDirectoryContents,
|
||||
}
|
||||
};
|
||||
//#endregion
|
||||
Reference in New Issue
Block a user