Skip to content

Commit 82e5ca6

Browse files
committed
Return RemoteFileAddress from parseRemoteFileAddress
1 parent 9ef8be7 commit 82e5ca6

3 files changed

Lines changed: 23 additions & 13 deletions

File tree

‎lib/entry-points.js‎

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/config/file.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ export async function getRemoteConfig(
4545
apiDetails: api.GitHubApiCombinedDetails,
4646
validateConfig: boolean,
4747
): Promise<UserConfig> {
48-
const groups = parseRemoteFileAddress(configFile);
48+
const address = parseRemoteFileAddress(configFile);
4949

5050
const response = await api
5151
.getApiClientWithExternalAuth(apiDetails)
5252
.rest.repos.getContent({
53-
owner: groups.owner,
54-
repo: groups.repo,
55-
path: groups.path,
56-
ref: groups.ref,
53+
owner: address.owner,
54+
repo: address.repo,
55+
path: address.path,
56+
ref: address.ref,
5757
});
5858

5959
let fileContents: string;

‎src/config/remote-file.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface RemoteFileAddress {
2020
* @returns The successful result of executing the regex.
2121
* @throws `ConfigurationError` if the format of `configFile` is not valid.
2222
*/
23-
export function parseRemoteFileAddress(configFile: string) {
23+
export function parseRemoteFileAddress(configFile: string): RemoteFileAddress {
2424
// retrieve the various parts of the config location, and ensure they're present
2525
const format = new RegExp(
2626
"(?<owner>[^/]+)/(?<repo>[^/]+)/(?<path>[^@]+)@(?<ref>.*)",
@@ -34,5 +34,10 @@ export function parseRemoteFileAddress(configFile: string) {
3434
);
3535
}
3636

37-
return pieces.groups;
37+
return {
38+
owner: pieces.groups.owner,
39+
repo: pieces.groups.repo,
40+
path: pieces.groups.path,
41+
ref: pieces.groups.ref,
42+
};
3843
}

0 commit comments

Comments
 (0)