Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit 9db269a

Browse files
feat(urlfetching): fetching project for the id
1 parent 75e240e commit 9db269a

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

index.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,23 @@ async function download(repository, options = Object.create(null)) {
4747

4848
// Create URL!
4949
const [org, repo] = repository.split(".");
50-
// TODO: get id
51-
const repositoryId = "";
50+
51+
const repositoryId = await new Promise((resolve, reject) => {
52+
https.get(`${GITLAB_URL.href}${org}%2F${repo}`, (response) => {
53+
if (response.statusCode === 404) {
54+
reject(Error(res.statusMessage));
55+
}
56+
let rawData = "";
57+
response.on("data", (buffer) => {
58+
rawData += buffer;
59+
});
60+
response.on("error", reject);
61+
response.on("end", () => {
62+
const jsonData = JSON.parse(rawData.toString());
63+
resolve(jsonData.id);
64+
});
65+
});
66+
});
5267

5368
const gitUrl = new URL(`${repositoryId}/repository/archive.tar.gz?ref=${branch}`, GITLAB_URL);
5469
const fileDestination = join(dest, `${repo}-${branch}.tar.gz`);

0 commit comments

Comments
 (0)