Skip to content

Commit a593198

Browse files
Added config-file arguments with an example
1 parent 15a215f commit a593198

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

examples/transform-config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"clean": true,
3+
"file": "./examples/openApiFiles/passportescaperoom.com.json",
4+
"outputFolder": "./examples/generated/angular2",
5+
"template": "angular2",
6+
"saveFile": "./openApiFiles/passportescaperoom.com"
7+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"start:webpack": "npx webpack --watch",
2828
"build": "tsc",
2929
"build:webpack": "npx webpack --mode production",
30-
"generate:examples": "npm start -- -f examples/openApiFiles/passportescaperoom.com.json -o examples/generated/angular2 -t angular2",
30+
"generate:examples": "npm start -- --config-file ./examples/transform-config.json",
3131
"test": "echo \"Error: no test specified\" && exit 1"
3232
},
3333
"license": "ISC",

src/services/arguments.service.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as yargs from 'yargs';
2+
import { readFileSync } from 'fs';
23

34
export const argumentsInstance = yargs
45
.alias('version', 'v')
@@ -9,6 +10,15 @@ export const argumentsInstance = yargs
910
'Convert a Swagger JSON file to compatible-angular API',
1011
)
1112

13+
.config('config-file', (configPath) => {
14+
return JSON.parse(readFileSync(configPath, 'utf-8'));
15+
})
16+
.describe(
17+
'config-file',
18+
'Configuration file to use (values from cli will overwrite the files one).',
19+
)
20+
.default('save-file', './openapi_temp')
21+
1222
.nargs('save-file', 1)
1323
.alias('s', 'save-file')
1424
.describe(

0 commit comments

Comments
 (0)