Adding better output of publish command
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Fabian Stamm 2020-07-31 20:18:28 +02:00
parent 7fcdf2c383
commit ef4ce98ebb
2 changed files with 24 additions and 17 deletions

View File

@ -44,7 +44,7 @@ export default async function publish() {
log("Uploading new package version");
const res = await fetch(url, {
await fetch(url, {
method: "POST",
body: await Deno.readFile(packedFile),
headers: {
@ -54,19 +54,22 @@ export default async function publish() {
getConfig("username") + ":" + getConfig("password")
),
},
}).then((res) => (res.status === 200 ? res.json() : res.statusText));
log("Upload finished. Result:", res);
if (typeof res === "string" || res.error) {
console.log(
Colors.red("Error: " + (typeof res == "string" ? res : res.error))
);
})
.then((res) =>
res.status === 200
? res.json()
: Promise.reject(new Error("res.statusText"))
)
.then((res) => {
if (!res.success) {
throw new Error(res.message);
} else {
if (res.success) {
console.log(Colors.green("Upload successfull"));
}
}
})
.catch((err) => {
console.log(Colors.red("Error: " + err.message));
});
} finally {
await Deno.remove(tmpDir, { recursive: true });
await Deno.remove(packedFile);

View File

@ -1,8 +1,12 @@
{
"name": "@denreg-cli",
"version": "0.1.2",
"version": "0.1.4",
"description": "CLI for the DenReg package registry",
"author": "Fabian Stamm <dev@fabianstamm.de>",
"contributors": [],
"files": ["**/*.ts", "**/*.js", "README.md"]
"files": [
"**/*.ts",
"**/*.js",
"README.md"
]
}