@@ -4,17 +4,13 @@ const jsonToGo = require('../vendor/json-to-go.js');
4
4
const buildPath = require ( './buildPath' ) ;
5
5
const { loadJsonOrYaml, isJsonString, loadConfig} = require ( "./common" ) ;
6
6
7
+ let cliOpts
7
8
8
- let configFile = "./.api-to-go.yml"
9
-
10
- function run ( urlStr , body , cliOpts ) {
11
- let comment
12
- let url
13
- let path
14
- let cfg
9
+ function run ( urlStr , body , options ) {
10
+ let comment , url , path , cfg
11
+ cliOpts = options
15
12
16
13
let opts = { }
17
-
18
14
try {
19
15
opts = buildOpts ( body , cliOpts )
20
16
} catch ( e ) {
@@ -29,8 +25,8 @@ function run(urlStr, body, cliOpts) {
29
25
console . log ( )
30
26
const apiUrl = urlStr . replace ( / \/ $ / , '' )
31
27
url = new URL ( apiUrl ) ;
32
- cfg = loadConfig ( url , configFile )
33
- path = buildPath ( url )
28
+ cfg = loadConfig ( url , cliOpts . config )
29
+ path = buildPath ( url , cliOpts . config )
34
30
35
31
console . log ( `API:` )
36
32
if ( cfg ?. [ "docs" ] !== undefined ) console . log ( ` Docs: ${ cfg ?. [ "docs" ] } ` )
@@ -111,7 +107,7 @@ function buildContent(go, path, comment) {
111
107
112
108
function buildComment ( url , path , method , res ) {
113
109
let comment = ""
114
- const cfg = loadConfig ( url , configFile )
110
+ const cfg = loadConfig ( url , cliOpts . config )
115
111
if ( cfg ?. [ "docs" ] !== undefined ) {
116
112
comment += `\n// Docs: ${ cfg ?. [ "docs" ] } `
117
113
}
0 commit comments