Skip to content

Commit

Permalink
Updates gen-feature to allow an array of files to extend from, and to…
Browse files Browse the repository at this point in the history
… only filter exclusions from those files (#74)

* Updates gen-feature command to allow extend arg as array of files

 - This will allow us to compose multiple feature files together.

* Updates gen-feature to apply exclusions only to the base set of features

 - It doesn't make sense to exclude features that are local, since typically we're extending with the sole purpose of adding them in.  This will make it so we can exclude things but not have to avoid clashing with local names (for instance, swapping out an app for a slightly extended version will no longer require making each have a unique name).
  • Loading branch information
andrewkfiedler authored Feb 12, 2020
1 parent 7247635 commit 22a942b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
6 changes: 5 additions & 1 deletion bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ program
program
.command('gen-feature')
.description('generate a feature file')
.option('-e, --extend <feature-file>', 'extend an existing feature file')
.option(
'-e, --extend [<feature-file>]',
'extend an existing feature file',
val => val.split(',')
)
.option('-x, --exclude [projects]', 'exclude existing wabs', val =>
val.split(',')
)
Expand Down
36 changes: 21 additions & 15 deletions lib/gen-feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,20 @@ const jetty = {
packaging: 'jar',
}

const extend = file => {
const features = fs.readFileSync(file, { encoding: 'utf8' })
const $ = cheerio.load(features, { xmlMode: true, decodeEntities: false })
return $('features > feature > bundle')
.map((i, el) =>
$(el)
.text()
.trim()
const extend = files => {
return files.reduce((list, file) => {
const features = fs.readFileSync(file, { encoding: 'utf8' })
const $ = cheerio.load(features, { xmlMode: true, decodeEntities: false })
return list.concat(
$('features > feature > bundle')
.map((i, el) =>
$(el)
.text()
.trim()
)
.get()
)
.get()
}, [])
}

const getBaseCoordinates = (args, project) => {
Expand Down Expand Up @@ -88,12 +92,14 @@ module.exports = ({ args, getPackage, getPom }) => {
version: project.version,
}))

const coors = base.concat(local.map(mvn)).filter(coor => {
if (!Array.isArray(args.exclude)) {
return true
}
return !args.exclude.some(arg => coor.match(arg))
})
const coors = base
.filter(coor => {
if (!Array.isArray(args.exclude)) {
return true
}
return !args.exclude.some(arg => coor.match(arg))
})
.concat(local.map(mvn))

const absolute = path.resolve('target/features.xml')

Expand Down

0 comments on commit 22a942b

Please sign in to comment.