Skip to content

Commit

Permalink
Added fix for files not being created on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav-from-contentstack committed Mar 15, 2021
1 parent 60b1980 commit 47bc353
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
8 changes: 6 additions & 2 deletions packages/export-to-csv/src/commands/cm/export-to-csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion packages/export-to-csv/src/util/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: /\'/
}
6 changes: 2 additions & 4 deletions packages/export-to-csv/src/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 47bc353

Please sign in to comment.