Skip to content

Commit 8460747

Browse files
committed
WIP: bugfix, support dry run execution
1 parent c8dc7ab commit 8460747

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

scenario-black-box.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ program
1010
.requiredOption('-c, --config <config>', 'Config file in json format', value => value)
1111
.option('-w, --workingDirectory <workingDirectory>', 'Working directory')
1212
.option('-r, --replace <replace>', 'Replace tags. Example: tag1:=value,tag2:=value . No space in string')
13+
.option('-e, --execution <execution>', 'Execution style dry or wet. Default is wet. -e dry|wet')
1314

1415
program.on('-h, --help', () => {
1516
console.log('')
1617
console.log('Example calls:')
1718
console.log(' $ scenario-generate --config config.json')
1819
console.log(' $ scenario-generate -c config.json')
20+
console.log(' $ scenario-generate -c config.json -e dry')
1921

2022
console.log(' $ scenario-generate --config config.json --replace url:=http://localhost:8080/led/api/v1,valuDate:=2022-10-01')
2123
console.log(' $ scenario-generate -c config.json -r url:=http://localhost:8080/led/api/v1,valuDate:=2022-10-01')
@@ -35,11 +37,16 @@ input.replace = {
3537

3638
const scenarioJson = scenarioAlgorithms.createScenarios(input)
3739

38-
sync.executeBlackBox(scenarioJson, 0)
39-
.then(data => {
40-
console.log(JSON.stringify(data, null, 2))
41-
})
42-
.catch(e => {
43-
console.log(e)
44-
})
40+
if (program.opts().execution && program.opts().execution.toLowerCase().includes('dry')) {
41+
console.log(JSON.stringify(scenarioJson, null, 2))
4542

43+
}
44+
else {
45+
sync.executeBlackBox(scenarioJson, 0)
46+
.then(data => {
47+
console.log(JSON.stringify(data, null, 2))
48+
})
49+
.catch(e => {
50+
console.log(e)
51+
})
52+
}

src/scenario-algorithm.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function toTechnology(technology) {
77
}
88

99
function replaceData(target, config) {
10-
if(target === undefined) {
10+
if (target === undefined) {
1111
return {}
1212
}
1313

@@ -59,6 +59,10 @@ function findReplaceRule(replaceRules, i, numOf) {
5959
}
6060

6161
function replaceAlways(target, replace, generateAlways) {
62+
if (!target) {
63+
return target
64+
}
65+
6266
const config = {
6367
...replace,
6468
...utils.generateReplace(generateAlways, replace)

0 commit comments

Comments
 (0)