diff --git a/packages/export-to-csv/src/commands/cm/export-to-csv.js b/packages/export-to-csv/src/commands/cm/export-to-csv.js index a0adaf140a..d06ab95cb2 100644 --- a/packages/export-to-csv/src/commands/cm/export-to-csv.js +++ b/packages/export-to-csv/src/commands/cm/export-to-csv.js @@ -27,7 +27,9 @@ class ExportToCsvCommand extends Command { let entries = await util.getEntries(this.managementAPIClient, stack.apiKey, contentType, language.code) // fetch entries let flatEntries = util.cleanEntries(entries.items, language.code, environments, contentType); // clean entries to be wderitten to file let dateTime = util.getDateTime() - let fileName = `${contentType}_${language.code}_entries_export_${dateTime}.csv` + // let fileName = `${contentType}_${language.code}_entries_export_${dateTime}.csv` + let fileName = `${stack.name}_${contentType}_${language.code}_entries_export.csv` + util.write(this, flatEntries, fileName) // write to file } break; @@ -41,7 +43,9 @@ class ExportToCsvCommand extends Command { const mappedRoles = util.getMappedRoles(orgRoles) const listOfUsers = util.cleanOrgUsers(orgUsers, mappedUsers, mappedRoles) const dateTime = util.getDateTime() - const fileName = `${util.kebabize(organization.name)}_users_export_${dateTime}.csv` + // const fileName = `${util.kebabize(organization.name.replace(config.organizationNameRegex, ''))}_users_export_${dateTime}.csv` + const fileName = `${util.kebabize(organization.name.replace(config.organizationNameRegex, ''))}_users_export.csv` + util.write(this, listOfUsers, fileName) } catch(error) { this.error(error) diff --git a/packages/export-to-csv/src/util/config.js b/packages/export-to-csv/src/util/config.js index 22f5e0262d..ac4655bc40 100644 --- a/packages/export-to-csv/src/util/config.js +++ b/packages/export-to-csv/src/util/config.js @@ -2,5 +2,6 @@ module.exports = { cancelString: 'Cancel and Exit', exportEntries: 'Export entries to a .CSV file', exportUsers: 'Export organization users\' data to a .CSV file', - adminError: 'Unable to export data. Make sure you\'re an admin or owner of this organization' + adminError: 'Unable to export data. Make sure you\'re an admin or owner of this organization', + organizationNameRegex: /\'/ } \ No newline at end of file diff --git a/packages/export-to-csv/src/util/index.js b/packages/export-to-csv/src/util/index.js index 3525b78184..a982ea39eb 100644 --- a/packages/export-to-csv/src/util/index.js +++ b/packages/export-to-csv/src/util/index.js @@ -246,12 +246,10 @@ function write(command, entries, fileName) { // eslint-disable-next-line no-undef process.chdir(directory) } - const ws = fs.createWriteStream(fileName) // eslint-disable-next-line no-undef - command.log(`Writing entries to file: ${process.cwd()}/${fileName}`) + command.log(`Writing entries to file: ${process.cwd()}${delimeter}${fileName}`) fastcsv - .write(entries, {headers: true}) - .pipe(ws) + .writeToPath(fileName, entries, {headers: true}) } function startupQuestions() {