Fix netrc tools
This commit is contained in:
parent
4c3dbb7acd
commit
9f167f12aa
|
@ -42,7 +42,7 @@ function writeSettings (settings) {
|
||||||
function getRemoteObjectOrDie (program: any, settings: Settings) {
|
function getRemoteObjectOrDie (program: any, settings: Settings) {
|
||||||
if (!program['url'] || !program['username'] || !program['password']) {
|
if (!program['url'] || !program['username'] || !program['password']) {
|
||||||
// No remote and we don't have program parameters: throw
|
// 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[ 'url' ]) console.error('--url field is required.')
|
||||||
if (!program[ 'username' ]) console.error('--username field is required.')
|
if (!program[ 'username' ]) console.error('--username field is required.')
|
||||||
if (!program[ 'password' ]) console.error('--password 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]
|
: settings.remotes[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!username) username = netrc.machines[url].login
|
const machine = netrc.machines[url]
|
||||||
if (!password) password = netrc.machines[url].password
|
if (!username) username = machine.login
|
||||||
|
if (!password) password = machine.password
|
||||||
|
|
||||||
return { url, username, password }
|
return { url, username, password }
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,8 @@ program
|
||||||
})
|
})
|
||||||
|
|
||||||
settings.remotes.forEach(element => {
|
settings.remotes.forEach(element => {
|
||||||
|
if (!netrc.machines[element]) return
|
||||||
|
|
||||||
table.push([
|
table.push([
|
||||||
element,
|
element,
|
||||||
netrc.machines[element].login
|
netrc.machines[element].login
|
||||||
|
|
Loading…
Reference in New Issue