Skip to content

Commit

Permalink
refactor: use find instead of complex reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
scolladon committed Jul 18, 2022
1 parent 276e6f1 commit 4df207a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/commands/sgd/source/ppset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,15 @@ export default class Ppset extends SfdxCommand {
const projectJson = await project.resolveProjectConfig()
const basePath = project.getPath()
const packageDirectories = projectJson['packageDirectories'] as JsonArray
const defaultDir = packageDirectories.reduce(
(a, v) => (v['default'] === true ? (a = v['path']) : (a = a)),
''
const defaultDirConfiguration = packageDirectories.find(
(dir: string) => dir['default'] === true
)

const sources = this.flags.sources || []
const userPermissions = this.flags['user-permissions'] || []
const dirList = packageDirectories.filter(dir => sources.includes(dir))
if (dirList.length === 0) {
dirList.push(defaultDir)
if (dirList.length === 0 && defaultDirConfiguration) {
dirList.push(defaultDirConfiguration['path'])
}

const xmlParser = new XMLParser(XML_PARSER_OPTION)
Expand Down

0 comments on commit 4df207a

Please sign in to comment.