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

feat(urlfetching): fetching project for the id #1

Merged
merged 1 commit into from
Feb 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,23 @@ async function download(repository, options = Object.create(null)) {

// Create URL!
const [org, repo] = repository.split(".");
// TODO: get id
const repositoryId = "";

const repositoryId = await new Promise((resolve, reject) => {
https.get(`${GITLAB_URL.href}${org}%2F${repo}`, (response) => {
if (response.statusCode === 404) {
reject(Error(res.statusMessage));
}
let rawData = "";
response.on("data", (buffer) => {
rawData += buffer;
});
response.on("error", reject);
response.on("end", () => {
const jsonData = JSON.parse(rawData.toString());
resolve(jsonData.id);
});
});
});

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