diff --git a/bin.js b/bin.js index f147223..2ae9cee 100755 --- a/bin.js +++ b/bin.js @@ -84,7 +84,11 @@ program program .command('gen-feature') .description('generate a feature file') - .option('-e, --extend ', 'extend an existing feature file') + .option( + '-e, --extend []', + 'extend an existing feature file', + val => val.split(',') + ) .option('-x, --exclude [projects]', 'exclude existing wabs', val => val.split(',') ) diff --git a/lib/gen-feature.js b/lib/gen-feature.js index c7c5197..dabb784 100644 --- a/lib/gen-feature.js +++ b/lib/gen-feature.js @@ -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) => { @@ -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')