Skip to content

Commit

Permalink
FIND_FILES update
Browse files Browse the repository at this point in the history
  • Loading branch information
khbsd committed May 22, 2024
1 parent 29a1ef5 commit ed364a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 8 additions & 1 deletion commands/debug2.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ const { getConfig } = require('../support_files/config');
const { CREATE_LOGGER, raiseError, raiseInfo } = require('../support_files/log_utils.js');
const bg3mh_logger = CREATE_LOGGER();

const { FIND_FILES_v2, getFormats } = require('../support_files/lslib_utils.js');

const debug2 = vscode.commands.registerCommand('bg3-mod-helper.debug2Command', async function () {
const config = getConfig();
const localizationPath = path.join(config.rootModPath, 'Localization');
let halfCoreCount = os.availableParallelism() / 2;

raiseInfo(`half of your cpu's cores: ${halfCoreCount}`);


try {
console.log(FIND_FILES_v2(".lsx"));
}
catch (err) {
console.error(err);
}


// after you are through with this command, the following line must be uncommented and the only thing left for this file to be considered cleaned up.
Expand Down
11 changes: 10 additions & 1 deletion support_files/lslib_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
const path = require('path');
const fs = require('fs');
const vscode = require('vscode');
const findFiles = vscode.workspace.findFiles;
const parse = vscode.Uri.parse;


// loads the api
Expand Down Expand Up @@ -168,6 +170,13 @@ function FIND_FILES(filesPath, targetExt = getFormats().lsf, isRecursive = true)
}


// beautiful. still needs dll handling in lslib_utils though
async function FIND_FILES_v2(targetExt = getFormats().lsf, filesPath = '**/*') {
const filesList = (await findFiles(filesPath + targetExt)).map(file => file.path);
return FILTER_PATHS(filesList);
}


function FILTER_PATHS(filesPath) {
let excludedFiles = getConfig().excludedFiles;
if (Array.isArray(filesPath)) {
Expand Down Expand Up @@ -232,4 +241,4 @@ function moveFileAcrossDevices(sourcePath, destPath, raiseError) {

const LSLIB = LOAD_LSLIB();

module.exports = { LSLIB, FIND_FILES, FILTER_PATHS, getFormats, moveFileAcrossDevices, baseNamePath, dirSeparator, compatRootModPath };
module.exports = { LSLIB, FIND_FILES, FIND_FILES_v2, FILTER_PATHS, getFormats, moveFileAcrossDevices, baseNamePath, dirSeparator, compatRootModPath };

0 comments on commit ed364a5

Please sign in to comment.