Skip to content

Commit f10fac5

Browse files
committed
select env and playbook
1 parent 2b498ee commit f10fac5

File tree

6 files changed

+56
-6
lines changed

6 files changed

+56
-6
lines changed

buildRun.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Copy-Item -Force -Recurse -Path $PSScriptRoot\playbooks\ -Destination $PSScriptR
44
Copy-Item -Force -Recurse -Path $PSScriptRoot\environments\ -Destination $PSScriptRoot\build
55
Copy-Item -Force -Recurse -Path $PSScriptRoot\runners\ -Destination $PSScriptRoot\build
66
npm test
7-
node $PSScriptRoot\build\engine\run.js --skipCommands.console dockerCompose
7+
node $PSScriptRoot\build\engine\run.js --skipCommands.console dockerCompose $args

buildRun.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ cp -r playbooks build
44
cp -r environments build
55
cp -r runners build
66
npm test
7-
node build/engine/run.js
7+
node build/engine/run.js $*

documentation/Development.md

+18
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,21 @@ public yourAssertionCode(): Assertions {
5555
```
5656
If you want to pass arguments to this method, you have to do this in the header of the 'run' method and in the call of the method.
5757

58+
## Choose the tutorial and the environment
59+
60+
### Environment
61+
flag: '-e'
62+
value: 'katacoda', 'console'
63+
64+
If you don't pass arguments to the file, it will run all environments.
65+
66+
#### example
67+
'bash localBuildRun.sh -e katacoda -e console'
68+
69+
### Playbook
70+
flag: '-p'
71+
value: foldername of the tutorial
72+
73+
'bash localBuildRun.sh -p cobigen-cli'
74+
75+

engine/run.ts

+33-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Playbook } from "./playbook";
33
import { Environment } from "./environment";
44
import { Engine } from "./engine";
55
import { isObject } from "util";
6+
import { type } from "os";
67
const fs = require('fs');
78
const yargs = require('yargs/yargs');
89

@@ -17,14 +18,17 @@ class Run {
1718
this.parseArgs();
1819
this.parsePlaybooks();
1920
this.parseEnvironments();
20-
for (let entry of Array.from(this.environments.entries())) {
21+
let entries = this.filterEnv(Array.from(this.environments.entries()))
22+
for (let entry of entries) {
2123
let key = entry[0];
2224
let value = entry[1];
23-
for (let playbookIndex in this.playbooks) {
25+
let playbookIndecies = this.filterPlaybooks(this.playbooks)
26+
for (let playbookIndex of playbookIndecies) {
2427
let engine = new Engine(key, value, this.playbooks[playbookIndex]);
2528

2629
for (let varEntry of Array.from(this.args.entries())) {
2730
engine.setVariable(varEntry[0], varEntry[1]);
31+
2832
}
2933

3034
try {
@@ -97,6 +101,33 @@ class Run {
97101
}
98102
}
99103
}
104+
105+
filterEnv(entries){
106+
if(!this.args.get('e'))
107+
return entries;
108+
109+
let filteredEntries=new Array();
110+
for(let entry of entries){
111+
if(this.args.get('e').includes(entry[0])){
112+
filteredEntries.push(entry)
113+
}
114+
}
115+
return filteredEntries
116+
}
117+
118+
filterPlaybooks(playbooks){
119+
if(!this.args.get('p'))
120+
return Array.from(playbooks.keys());
121+
122+
let filteredIndecies = [];
123+
for(let playbook of playbooks){
124+
if(this.args.get('p').includes(playbook['name'].replace("/", ""))){
125+
filteredIndecies.push(playbooks.indexOf(playbook))
126+
127+
}
128+
}
129+
return filteredIndecies
130+
}
100131
}
101132

102133

localBuildRun.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Copy-Item -Force -Recurse -Path $PSScriptRoot\environments\ -Destination $PSScri
55
Copy-Item -Force -Recurse -Path $PSScriptRoot\runners\ -Destination $PSScriptRoot\build
66
npm test
77
if(-not $?) { throw 'tests failed' }
8-
node $PSScriptRoot\build\engine\run.js
8+
node $PSScriptRoot\build\engine\run.js $args

localBuildRun.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ if [ $? -eq 1 ]; then
88
echo 'tests failed'
99
exit 1
1010
fi
11-
node build/engine/run.js
11+
12+
node build/engine/run.js $*

0 commit comments

Comments
 (0)