@@ -31,29 +31,29 @@ export async function getConfigFile(
31
31
}
32
32
33
33
// https://docs.github.com/en/rest/reference/repos#get-repository-content
34
- const requestOptions = await octokit . request . endpoint (
35
- "GET /repos/{owner}/{repo}/contents/{path} " ,
36
- {
37
- owner,
38
- repo,
39
- path,
40
- mediaType : {
41
- format : "raw" ,
42
- } ,
43
- // this can be just `ref` once https://github.com/octokit/endpoint.js/issues/206 is resolved
44
- ...( ref ? { ref } : { } ) ,
45
- }
46
- ) ;
34
+ const endpoint = {
35
+ method : "GET" ,
36
+ url : "/repos/{owner}/{repo}/contents/{path}" ,
37
+ owner,
38
+ repo,
39
+ path,
40
+ mediaType : {
41
+ format : "raw" ,
42
+ } ,
43
+ // this can be just `ref` once https://github.com/octokit/endpoint.js/issues/206 is resolved
44
+ ...( ref ? { ref } : { } ) ,
45
+ } ;
46
+ const { url } = await octokit . request . endpoint ( endpoint ) ;
47
47
const emptyConfigResult = {
48
48
owner,
49
49
repo,
50
50
path,
51
- url : requestOptions . url ,
51
+ url,
52
52
config : null ,
53
53
} ;
54
54
55
55
try {
56
- const { data, headers } = await octokit . request ( requestOptions ) ;
56
+ const { data, headers } = await octokit . request ( endpoint ) ;
57
57
58
58
// If path is a submodule, or a folder, then a JSON string is returned with
59
59
// the "Content-Type" header set to "application/json; charset=utf-8".
@@ -65,14 +65,14 @@ export async function getConfigFile(
65
65
// so we are fine
66
66
if ( headers [ "content-type" ] === "application/json; charset=utf-8" ) {
67
67
throw new Error (
68
- `[@probot/octokit-plugin-config] ${ requestOptions . url } exists, but is either a directory or a submodule. Ignoring.`
68
+ `[@probot/octokit-plugin-config] ${ url } exists, but is either a directory or a submodule. Ignoring.`
69
69
) ;
70
70
}
71
71
72
72
if ( fileExtension === "json" ) {
73
73
if ( typeof data === "string" ) {
74
74
throw new Error (
75
- `[@probot/octokit-plugin-config] Configuration could not be parsed from ${ requestOptions . url } (invalid JSON)`
75
+ `[@probot/octokit-plugin-config] Configuration could not be parsed from ${ url } (invalid JSON)`
76
76
) ;
77
77
}
78
78
@@ -86,7 +86,7 @@ export async function getConfigFile(
86
86
87
87
if ( typeof config === "string" ) {
88
88
throw new Error (
89
- `[@probot/octokit-plugin-config] Configuration could not be parsed from ${ requestOptions . url } (YAML is not an object)`
89
+ `[@probot/octokit-plugin-config] Configuration could not be parsed from ${ url } (YAML is not an object)`
90
90
) ;
91
91
}
92
92
@@ -105,7 +105,7 @@ export async function getConfigFile(
105
105
: "invalid YAML" ;
106
106
107
107
throw new Error (
108
- `[@probot/octokit-plugin-config] Configuration could not be parsed from ${ requestOptions . url } (${ reason } )`
108
+ `[@probot/octokit-plugin-config] Configuration could not be parsed from ${ url } (${ reason } )`
109
109
) ;
110
110
}
111
111
0 commit comments