aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-26 15:16:48 +0200
committerChocobozzz <me@florianbigard.com>2018-09-26 15:16:48 +0200
commit542e73a26bac2bfea94b5db013bdebe0cb4d3917 (patch)
tree3c40bcb711630ecf5bce06cf7322f40cea1d98f2 /server/tools
parent9ffdd52a95d596ce3d0084baa8541748326edb9c (diff)
downloadPeerTube-542e73a26bac2bfea94b5db013bdebe0cb4d3917.tar.gz
PeerTube-542e73a26bac2bfea94b5db013bdebe0cb4d3917.tar.zst
PeerTube-542e73a26bac2bfea94b5db013bdebe0cb4d3917.zip
Improve upliad script error handling for token
Diffstat (limited to 'server/tools')
-rw-r--r--server/tools/peertube-upload.ts16
1 files changed, 12 insertions, 4 deletions
diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts
index 1f871e660..927564b14 100644
--- a/server/tools/peertube-upload.ts
+++ b/server/tools/peertube-upload.ts
@@ -75,7 +75,10 @@ getSettings()
75 process.exit(-1) 75 process.exit(-1)
76 } 76 }
77 77
78 run().catch(err => console.error(err)) 78 run().catch(err => {
79 console.error(err)
80 process.exit(-1)
81 })
79 }) 82 })
80 83
81async function run () { 84async function run () {
@@ -90,8 +93,13 @@ async function run () {
90 password: program[ 'password' ] 93 password: program[ 'password' ]
91 } 94 }
92 95
93 const res2 = await login(program[ 'url' ], client, user) 96 let accessToken: string
94 const accessToken = res2.body.access_token 97 try {
98 const res2 = await login(program[ 'url' ], client, user)
99 accessToken = res2.body.access_token
100 } catch (err) {
101 throw new Error('Cannot authenticate. Please check your username/password.')
102 }
95 103
96 await access(program[ 'file' ], constants.F_OK) 104 await access(program[ 'file' ], constants.F_OK)
97 105
@@ -114,7 +122,7 @@ async function run () {
114 support: undefined 122 support: undefined
115 } 123 }
116 124
117 await uploadVideo(program['url'], accessToken, videoAttributes) 125 await uploadVideo(program[ 'url' ], accessToken, videoAttributes)
118 126
119 console.log(`Video ${program['videoName']} uploaded.`) 127 console.log(`Video ${program['videoName']} uploaded.`)
120 process.exit(0) 128 process.exit(0)