@xiaobai-world/upload
Advanced tools
Comparing version 0.0.70 to 0.0.71
{ | ||
"name": "@xiaobai-world/upload", | ||
"version": "0.0.70", | ||
"version": "0.0.71", | ||
"description": "upload to xiaobai store", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -6,3 +6,2 @@ const prompts = require("prompts"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const { getXiaobaiConfigPath, getAxiosHeader } = require("./utils"); | ||
@@ -15,14 +14,11 @@ | ||
async function login() { | ||
console.log(chalk.green("Logining in...")); | ||
try { | ||
const user = await axios.get(`${base}/user/info`, { | ||
headers: { | ||
...getAxiosHeader(), | ||
}, | ||
}); | ||
if (user.data && user.data.email) { | ||
return user.data; | ||
} | ||
} catch (e) { | ||
// show login ui | ||
console.log(chalk.green("Logining in..."), base); | ||
const user = await axios.get(`${base}/user/info`, { | ||
headers: { | ||
...getAxiosHeader(), | ||
}, | ||
}); | ||
if (user.data && user.data.email) { | ||
return user.data; | ||
} | ||
@@ -48,7 +44,7 @@ | ||
.catch((e) => { | ||
return e.response; | ||
return e; | ||
}); | ||
if (login.status !== 201) { | ||
return null; | ||
throw new Error("Login fail"); | ||
} | ||
@@ -55,0 +51,0 @@ |
@@ -10,3 +10,3 @@ const fs = require("fs"); | ||
function getXiaobaiConfigPath() { | ||
return path.join(process.env.HOME, `xiaobai-world-config-${baseHash}.json`); | ||
return path.join(process.env.HOME, `.xiaobai-world-config-${baseHash}.json`); | ||
} | ||
@@ -13,0 +13,0 @@ |
9522
280