Skip to content

Commit

Permalink
feat: remove unnecesary netrc handling warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Oct 29, 2024
1 parent c63d382 commit 3235497
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/commands/logout/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isAuthorized, removeAllNetrcEntries, removeNetrcEntry } from '../../creds'
import { isAuthorized, removeAllNetrcEntries } from '../../creds'
import { commands } from '../../constants'
import { getProgram } from '../../program'
import { handleError, konsola } from '../../utils'
Expand Down
16 changes: 4 additions & 12 deletions src/creds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,10 @@ export const addNetrcEntry = async ({
let machines: Record<string, NetrcMachine> = {}

// Check if the file exists
try {
await access(filePath)
// File exists, read and parse it
const content = await readFile(filePath, 'utf8')
machines = parseNetrcContent(content)
}
catch {
// File does not exist
konsola.warn(`.netrc file not found at path: ${filePath}. A new file will be created.`)
}
await access(filePath)
// File exists, read and parse it
const content = await readFile(filePath, 'utf8')
machines = parseNetrcContent(content)

// Add or update the machine entry
machines[machineName] = {
Expand Down Expand Up @@ -210,8 +204,6 @@ export const removeNetrcEntry = async (
machines = parseNetrcContent(content)
}
catch {
// File does not exist
konsola.warn(`.netrc file not found at path: ${filePath}. No action taken.`)
return
}

Expand Down

0 comments on commit 3235497

Please sign in to comment.