From 9f167f12aafbcdda2e2cd2f436ff996ea41986ba Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 Jun 2019 09:25:20 +0200 Subject: Fix netrc tools --- server/tools/cli.ts | 7 ++++--- server/tools/peertube-auth.ts | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'server/tools') diff --git a/server/tools/cli.ts b/server/tools/cli.ts index 59e9fcfc4..e83a8a63c 100644 --- a/server/tools/cli.ts +++ b/server/tools/cli.ts @@ -42,7 +42,7 @@ function writeSettings (settings) { function getRemoteObjectOrDie (program: any, settings: Settings) { if (!program['url'] || !program['username'] || !program['password']) { // No remote and we don't have program parameters: throw - if (settings.remotes.length === 0) { + if (settings.remotes.length === 0 || Object.keys(netrc.machines).length === 0) { if (!program[ 'url' ]) console.error('--url field is required.') if (!program[ 'username' ]) console.error('--username field is required.') if (!program[ 'password' ]) console.error('--password field is required.') @@ -60,8 +60,9 @@ function getRemoteObjectOrDie (program: any, settings: Settings) { : settings.remotes[0] } - if (!username) username = netrc.machines[url].login - if (!password) password = netrc.machines[url].password + const machine = netrc.machines[url] + if (!username) username = machine.login + if (!password) password = machine.password return { url, username, password } } diff --git a/server/tools/peertube-auth.ts b/server/tools/peertube-auth.ts index 8bc3d332c..e53283fbe 100644 --- a/server/tools/peertube-auth.ts +++ b/server/tools/peertube-auth.ts @@ -93,6 +93,8 @@ program }) settings.remotes.forEach(element => { + if (!netrc.machines[element]) return + table.push([ element, netrc.machines[element].login -- cgit v1.2.3