Skip to content

Commit

Permalink
fix: appropriately handle non-existent folders
Browse files Browse the repository at this point in the history
fixes #9
  • Loading branch information
mikejgray committed Aug 25, 2023
1 parent 581f2a6 commit c781e1a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,14 @@ ${line}`;
*/
restructureLocaleFolders(sourceFolder: string) {
['vocab', 'dialog', 'regex', 'intents'].forEach((dir) => {
const dirPath = join(sourceFolder, dir);

// Check if the directory exists before proceeding
if (!existsSync(dirPath)) {
console.warn(`${dir} folder not found in original skill; skipping.`);
return; // Continue to the next iteration of the loop
}

const locale = join(sourceFolder, 'locale');
try {
mkdirSync(locale, { recursive: true });
Expand All @@ -429,9 +437,8 @@ ${line}`;
renameSync(join(sourceFolder, dir, lang), join(locale, lang, dir));
}
});

} catch (err) {
console.debug(err);
console.error(err);
}
});
}
Expand Down

0 comments on commit c781e1a

Please sign in to comment.