fixed script to fail on upload failure

This commit is contained in:
Philip Ellis
2023-09-27 15:56:20 -05:00
parent 426a8a46c8
commit 644b6d038b
2 changed files with 15 additions and 7 deletions

View File

@@ -114,6 +114,17 @@ async function uploadCollection() {
async function main() {
try {
const response = await getCollections();
if (!response.collections) {
console.log(response)
throw new Error("Postman API threw an error");
}
const upload = await uploadCollection();
if (!upload.collection) {
console.log(upload)
throw new Error("Postman API threw an error");
}
console.log(upload);
fs.writeFileSync('postman/links/' + args[3].toLowerCase() + '-link.txt','https://god.gw.postman.com/run-collection/' + upload.collection.uid + '?action=collection%2Ffork&collection-url=entityId%3D' + upload.collection.uid + '%26entityType%3Dcollection%26workspaceId%3D80af54be-a333-4712-af5e-41aa9eccbdd0')
for (let collection of response.collections) {
if (collection.name.includes(args[3])) {
console.log(collection);
@@ -121,9 +132,6 @@ async function main() {
console.log(response);
}
}
const upload = await uploadCollection();
console.log(upload);
fs.writeFileSync('postman/links/' + args[3].toLowerCase() + '-link.txt','https://god.gw.postman.com/run-collection/' + upload.collection.uid + '?action=collection%2Ffork&collection-url=entityId%3D' + upload.collection.uid + '%26entityType%3Dcollection%26workspaceId%3D80af54be-a333-4712-af5e-41aa9eccbdd0')
} catch (error) {
console.error(error);
}

View File

@@ -1 +1 @@
https://god.gw.postman.com/run-collection/23226990-6666a82e-d785-4fa0-b9f8-c1a3a63533e9?action=collection%2Ffork&collection-url=entityId%3D23226990-6666a82e-d785-4fa0-b9f8-c1a3a63533e9%26entityType%3Dcollection%26workspaceId%3D80af54be-a333-4712-af5e-41aa9eccbdd0
https://god.gw.postman.com/run-collection/23226990-0f1c5334-ce2e-4b32-b516-cff77c38097f?action=collection%2Ffork&collection-url=entityId%3D23226990-0f1c5334-ce2e-4b32-b516-cff77c38097f%26entityType%3Dcollection%26workspaceId%3D80af54be-a333-4712-af5e-41aa9eccbdd0