Skip to content

Commit

Permalink
added directoryExists and fileExists to fileHelpers
Browse files Browse the repository at this point in the history
fixed bug with removeOldMergeFiles
  • Loading branch information
matortheeternal committed Aug 26, 2021
1 parent bdb0bb8 commit bc3b33e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/javascripts/Services/merge/mergeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ ngapp.service('mergeBuilder', function($q, $rootScope, progressLogger, mergeServ
merge.dataPath = mergeService.getMergeDataPath(merge);
if (!merge.method) merge.method = DEFAULT_MERGE_METHOD;
merge.failedToCopy = [];
removeOldMergeFiles(merge);
if (fh.directoryExists(merge.dataPath))
removeOldMergeFiles(merge);
let mergeFolderPath = `${merge.dataPath}\\merge - ${merge.name}`;
progressLogger.init('merge', mergeFolderPath);
log(`\r\nBuilding merge ${merge.name}`);
Expand Down
16 changes: 16 additions & 0 deletions src/javascripts/helpers/fileHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ fh.path = jetpack.path;
// log app directory for reference
console.log('App directory: ' + fh.appPath);

fh.directoryExists = function(path) {
try {
return jetpack.exists(path) === 'dir';
} catch (x) {
return false;
}
};

fh.fileExists = function(path) {
try {
return jetpack.exists(path) === 'file';
} catch (x) {
return false;
}
};

fh.loadJsonFile = function(filePath) {
if (jetpack.exists(filePath) === 'file')
return jetpack.read(filePath, 'json');
Expand Down

0 comments on commit bc3b33e

Please sign in to comment.