You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ta...@apache.org on 2019/03/27 18:14:25 UTC
[incubator-openwhisk-composer] branch file-output created (now
ab73033)
This is an automated email from the ASF dual-hosted git repository.
tardieu pushed a change to branch file-output
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-composer.git.
at ab73033 Add compose --file and -o flags
This branch includes the following new commits:
new ab73033 Add compose --file and -o flags
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[incubator-openwhisk-composer] 01/01: Add compose --file and -o
flags
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tardieu pushed a commit to branch file-output
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-composer.git
commit ab730334809835363b060e83d3a3882d48b1db64
Author: Olivier Tardieu <ta...@us.ibm.com>
AuthorDate: Wed Mar 27 14:11:58 2019 -0400
Add compose --file and -o flags
---
bin/compose.js | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/bin/compose.js b/bin/compose.js
index e426d13..a9cd01a 100755
--- a/bin/compose.js
+++ b/bin/compose.js
@@ -18,14 +18,15 @@
const composer = require('../composer')
const conductor = require('../conductor')
+const fs = require('fs')
const json = require('../package.json')
const minimist = require('minimist')
const Module = require('module')
const path = require('path')
const argv = minimist(process.argv.slice(2), {
- string: ['debug'],
- boolean: ['version', 'ast', 'js'],
+ string: ['debug', 'o'],
+ boolean: ['version', 'ast', 'js', 'file'],
alias: { version: 'v' }
})
@@ -53,7 +54,9 @@ if (argv._.length !== 1 || path.extname(argv._[0]) !== '.js') {
console.error(' compose composition.js [flags]')
console.error('Flags:')
console.error(' --ast only output the ast for the composition')
+ console.error(' --file write output to .json file with path and name matching input file')
console.error(' --js output the conductor action code for the composition')
+ console.error(' -o FILE write output to FILE')
console.error(' -v, --version output the composer version')
console.error(' --debug LIST comma-separated list of debug flags (when using --js flag)')
process.exit(1)
@@ -72,5 +75,13 @@ if (argv.js) {
console.log(conductor.generate(composition, argv.debug).action.exec.code)
} else {
if (argv.ast) composition = composition.ast
- console.log(JSON.stringify(composition, null, 4))
+ composition = JSON.stringify(composition, null, 4)
+ if (argv.o) {
+ fs.writeFileSync(argv.o, composition.concat('\n'), { encoding: 'utf8' })
+ } else if (argv.file) {
+ const { dir, name } = path.parse(argv._[0])
+ fs.writeFileSync(path.format({ dir, name, ext: '.json' }), composition.concat('\n'), { encoding: 'utf8' })
+ } else {
+ console.log(composition)
+ }
}