diff options
author | Chocobozzz <me@florianbigard.com> | 2019-06-11 09:25:20 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-06-11 09:25:20 +0200 |
commit | 9f167f12aafbcdda2e2cd2f436ff996ea41986ba (patch) | |
tree | b833240d5b40f49ca6ae3cdd50bdb18104eb34d7 /server/tools/cli.ts | |
parent | 4c3dbb7acd1d6be4697cfd319022b9a9fae6725b (diff) | |
download | PeerTube-9f167f12aafbcdda2e2cd2f436ff996ea41986ba.tar.gz PeerTube-9f167f12aafbcdda2e2cd2f436ff996ea41986ba.tar.zst PeerTube-9f167f12aafbcdda2e2cd2f436ff996ea41986ba.zip |
Fix netrc tools
Diffstat (limited to 'server/tools/cli.ts')
-rw-r--r-- | server/tools/cli.ts | 7 |
1 files changed, 4 insertions, 3 deletions
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) { | |||
42 | function getRemoteObjectOrDie (program: any, settings: Settings) { | 42 | function getRemoteObjectOrDie (program: any, settings: Settings) { |
43 | if (!program['url'] || !program['username'] || !program['password']) { | 43 | if (!program['url'] || !program['username'] || !program['password']) { |
44 | // No remote and we don't have program parameters: throw | 44 | // No remote and we don't have program parameters: throw |
45 | if (settings.remotes.length === 0) { | 45 | if (settings.remotes.length === 0 || Object.keys(netrc.machines).length === 0) { |
46 | if (!program[ 'url' ]) console.error('--url field is required.') | 46 | if (!program[ 'url' ]) console.error('--url field is required.') |
47 | if (!program[ 'username' ]) console.error('--username field is required.') | 47 | if (!program[ 'username' ]) console.error('--username field is required.') |
48 | if (!program[ 'password' ]) console.error('--password field is required.') | 48 | if (!program[ 'password' ]) console.error('--password field is required.') |
@@ -60,8 +60,9 @@ function getRemoteObjectOrDie (program: any, settings: Settings) { | |||
60 | : settings.remotes[0] | 60 | : settings.remotes[0] |
61 | } | 61 | } |
62 | 62 | ||
63 | if (!username) username = netrc.machines[url].login | 63 | const machine = netrc.machines[url] |
64 | if (!password) password = netrc.machines[url].password | 64 | if (!username) username = machine.login |
65 | if (!password) password = machine.password | ||
65 | 66 | ||
66 | return { url, username, password } | 67 | return { url, username, password } |
67 | } | 68 | } |