Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit 16c3aa8

Browse files
committed
bug fix for repl's handling of implicit arguments
Fixes #947
1 parent 04c9905 commit 16c3aa8

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

app/content/js/repl.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,8 @@ self.exec = (commandUntrimmed, execOptions) => {
851851
nRequiredArgs = required.length + (oneof.length > 0 ? 1 : 0) - nPositionalsConsumed,
852852
optLikeActuals = optLikeOneOfs.filter(({name, alias=''}) => parsedOptions.hasOwnProperty(unflag(name)) || parsedOptions.hasOwnProperty(unflag(alias))),
853853
nOptLikeActuals = optLikeActuals.length,
854-
nActualArgs = args.length - args.indexOf(cmd) - 1 + nOptLikeActuals
854+
cmdArgsStart = args.indexOf(cmd),
855+
nActualArgs = args.length - cmdArgsStart - 1 + nOptLikeActuals
855856

856857
// did the user pass an unsupported optional parameter?
857858
for (let optionalArg in parsedOptions) {
@@ -946,8 +947,8 @@ self.exec = (commandUntrimmed, execOptions) => {
946947

947948
} else {
948949
// ooh, then splice in the implicit parameter
949-
args.splice(implicitIdx, 0, `/${selection.namespace}/${selection.name}`)
950-
debug('spliced in implicit argument', implicitIdx, args[implicitIdx])
950+
args.splice(implicitIdx, cmdArgsStart + 1, selection.namespace ? `/${selection.namespace}/${selection.name}` : selection.name)
951+
debug('spliced in implicit argument', cmdArgsStart, implicitIdx, args)
951952
}
952953
}
953954
}

tests/tests/passes/07/composer-viz.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ describe('show the composer visualization without creating openwhisk assets', fu
131131

132132
/** test: viz, then create with no args, testing for handling of implicit entity */
133133
it(`should create with implicit entity`, () => cli.do('app create', this.app)
134-
.then(verifyTheBasicStuff(seq.file.replace(/\.[^\.]*/,''), 'composerLib')) // the .replace part strips off the ".js" suffix
134+
.then(verifyTheBasicStuff(seq.file, 'composerLib'))
135135
.then(verifyNodeExists('seq1', false)) // not deployed
136136
.then(verifyNodeExists('seq2', false)) // not deployed
137137
.then(verifyNodeExists('seq3', false)) // not deployed
@@ -158,7 +158,7 @@ describe('show the composer visualization without creating openwhisk assets', fu
158158

159159
/** test: viz, then create with -r, testing for handling of implicit entity and auto-deploy */
160160
it(`should create wookiechat and dependent actions with implicit entity`, () => cli.do('app update -r', this.app)
161-
.then(verifyTheBasicStuff('app', 'composerLib')) // the .replace part strips off the ".js" suffix
161+
.then(verifyTheBasicStuff('app.js', 'composerLib'))
162162
.then(verifyNodeExists('swapi', true)) // expect to be deployed
163163
.then(verifyNodeExists('stapi', true)) // expect to be deployed
164164
.then(verifyNodeExists('validate-swapi', true)) // expect to be deployed

0 commit comments

Comments
 (0)