Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated capture.js (v1) to output errors in case of failure. #1011

Merged
merged 2 commits into from
Oct 31, 2020
Merged
Changes from 1 commit
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
25 changes: 16 additions & 9 deletions scripts/capture.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Important: this script is no longer maintained; new scripts are located in the scripts.v2 folder.
*/

const fs = require("fs");
const https = require("https");
const managementEndpoint = process.argv[2];
Expand All @@ -22,18 +18,21 @@ async function request(url) {
return new Promise((resolve, reject) => {
const req = https.request(url, options, (resp) => {
let data = "";

resp.on("data", (chunk) => {
data += chunk;
});

resp.on("end", () => {
// reject on bad status
if (resp.statusCode != 200) {
console.log('url: ' + url);
return reject(new Error('statusCode=' + resp.statusCode + ' for URL: ' + url));
}
try {
resolve(JSON.parse(data));
}
catch (e) {
catch (e) {;
azaslonov marked this conversation as resolved.
Show resolved Hide resolved
reject(e);
console.log(url);
console.log(url);
}
});
});
Expand All @@ -46,6 +45,7 @@ async function request(url) {
});
}


async function getContentTypes() {
const data = await request(`https://${managementEndpoint}/contentTypes?api-version=2018-06-01-preview`);
const contentTypes = data.value.map(x => x.id.replace("\/contentTypes\/", ""));
Expand Down Expand Up @@ -99,4 +99,11 @@ async function capture() {

capture().then(() => {
console.log("DONE");
})
}).catch((err) => {
console.log(err);
});