8000 getModuleInfo · avdim/github-script@f609b5a · GitHub
[go: up one dir, main page]

Skip to content

Commit f609b5a

Browse files
committed
getModuleInfo
1 parent 407e12d commit f609b5a

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

__test__/npm-api.test.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,7 @@ describe('npm-api', () => {
3535
//https://github.com/npm/npm-registry-client
3636
//https://github.com/postmanlabs/npm-cli-login/blob/master/lib/login.js#L51
3737
await publishAsync(REGISTRY, TGZ_PATH, MODULE_NAME, AUTH)
38-
39-
// REG_CLIENT.get(
40-
// REGISTRY,
41-
// {
42-
// auth: AUTH,
43-
// fullMetadata: true
44-
// },
45-
// (err: any, data: any) => {
46-
// if (err) {
47-
// console.log("err: ", err)
48-
// } else {
49-
// console.log("regClient.get data: ", data)
50-
// }
51-
// }
52-
// );
53-
38+
expect(await getModuleInfo(REGISTRY, MODULE_NAME, "1.0.1", AUTH) != undefined).toEqual(true)
5439
})
5540

5641
})
@@ -77,7 +62,6 @@ async function publishAsync(registryUrl: string, tgzPath: string, moduleName: st
7762
console.log("err: ", err)
7863
reject(err)
7964
} else {
80-
console.log("regClient.publish data: ", data)
8165
resolve(data)
8266
}
8367
}
@@ -86,3 +70,25 @@ async function publishAsync(registryUrl: string, tgzPath: string, moduleName: st
8670
});
8771
}
8872

73+
async function getModuleInfo(registryUrl: string, moduleName:String, version:string, auth: any): Promise<unknown> {
74+
let regInfo:any = await new Promise((resolve: (value?: unknown) => void, reject: (reason?: any) => void) => {
75+
const regClient = new RegClient();
76+
regClient.get(
77+
registryUrl + `/${moduleName}`,
78+
{
79+
auth: auth,
80+
fullMetadata: true
81+
},
82+
(err: any, data: any) => {
83+
if (err) {
84+
console.log("err: ", err)
85+
reject(err)
86+
} else {
87+
resolve(data)
88+
}
89+
}
90+
);
91+
});
92+
return regInfo.versions[version]
93+
}
94+

0 commit comments

Comments
 (0)
0