diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-26 15:16:48 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-09-26 15:16:48 +0200 |
commit | 542e73a26bac2bfea94b5db013bdebe0cb4d3917 (patch) | |
tree | 3c40bcb711630ecf5bce06cf7322f40cea1d98f2 | |
parent | 9ffdd52a95d596ce3d0084baa8541748326edb9c (diff) | |
download | PeerTube-542e73a26bac2bfea94b5db013bdebe0cb4d3917.tar.gz PeerTube-542e73a26bac2bfea94b5db013bdebe0cb4d3917.tar.zst PeerTube-542e73a26bac2bfea94b5db013bdebe0cb4d3917.zip |
Improve upliad script error handling for token
-rw-r--r-- | server/tools/peertube-upload.ts | 16 |
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 | ||
81 | async function run () { | 84 | async 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) |