Skip to content

Commit

Permalink
Merge pull request #292 from trivir/feature/journey-export-tests
Browse files Browse the repository at this point in the history
Fix journey exports and add journey export tests
  • Loading branch information
vscheuber authored Oct 7, 2023
2 parents 9040fbd + b2c5bb5 commit dc88ceb
Show file tree
Hide file tree
Showing 3 changed files with 16,443 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/ops/JourneyOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,17 @@ export async function exportJourneysToFile(
): Promise<void> {
let fileName = file;
if (!fileName) {
fileName = getTypedFilename(`all${getRealmString()}Journeys`, 'journeys');
fileName = getTypedFilename(`all${getRealmString()}Journeys`, 'journey');
}
if (state.getDirectory()) {
const dir = state.getDirectory().replace(/\/$/, '');
debugMessage(`exportJourneysToFile: directory='${dir}'`);
fileName = `${dir}/${fileName}`;
// create directory if it doesn't exist
if (!fs.existsSync(dir)) {
debugMessage(`exportJourneysToFile: creating directory '${dir}'`);
fs.mkdirSync(dir, { recursive: true });
}
}
const trees = await readJourneys();
const fileData: MultiTreeExportInterface = createMultiTreeExportTemplate();
Expand All @@ -215,11 +225,23 @@ export async function exportJourneysToFile(
export async function exportJourneysToFiles(
options: TreeExportOptions
): Promise<void> {
const dir = state.getDirectory()
? state.getDirectory().replace(/\/$/, '')
: undefined;
debugMessage(`exportJourneysToFiles: directory='${dir}'`);
// create directory if it doesn't exist
if (dir && !fs.existsSync(dir)) {
debugMessage(`exportJourneysToFiles: creating directory '${dir}'`);
fs.mkdirSync(dir, { recursive: true });
}
const trees = await readJourneys();
createProgressBar(trees.length, 'Exporting journeys...');
for (const tree of trees) {
updateProgressBar(`${tree._id}`);
const fileName = getTypedFilename(`${tree._id}`, 'journey');
let fileName = getTypedFilename(`${tree._id}`, 'journey');
if (dir) {
fileName = `${dir}/${fileName}`;
}
try {
const exportData: SingleTreeExportInterface = await exportJourney(
tree._id,
Expand Down
Loading

0 comments on commit dc88ceb

Please sign in to comment.