Skip to content

Commit

Permalink
Added a function to convert organization name to kebab case
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav-from-contentstack committed Mar 14, 2021
1 parent 1a86577 commit 60b1980
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/export-to-csv/src/commands/cm/export-to-csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ExportToCsvCommand extends Command {
const mappedRoles = util.getMappedRoles(orgRoles)
const listOfUsers = util.cleanOrgUsers(orgUsers, mappedUsers, mappedRoles)
const dateTime = util.getDateTime()
const fileName = `${organization.name}_users_export_${dateTime}.csv`
const fileName = `${util.kebabize(organization.name)}_users_export_${dateTime}.csv`
util.write(this, listOfUsers, fileName)
} catch(error) {
this.error(error)
Expand Down
7 changes: 6 additions & 1 deletion packages/export-to-csv/src/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,11 @@ function cleanOrgUsers(orgUsers, mappedUsers, mappedRoles) {
userList.push(formattedUser)
})
return userList
}
}

function kebabize(str) {
return str.split(' ').map((word) => word.toLowerCase()).join('-')
}

module.exports = {
chooseOrganization: chooseOrganization,
Expand All @@ -364,4 +368,5 @@ module.exports = {
cleanOrgUsers: cleanOrgUsers,
determineUserOrgRole: determineUserOrgRole,
getOrganizationsWhereUserIsAdmin: getOrganizationsWhereUserIsAdmin,
kebabize: kebabize,
}

0 comments on commit 60b1980

Please sign in to comment.