8000 feat: update users .npmrc in place instead of replacing it · mrvus/azdo-npm-auth@c88d6f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit c88d6f7

Browse files
authored
feat: update users .npmrc in place instead of replacing it
1 parent cd7c6be commit c88d6f7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/writeNpmrc.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ export async function writeNpmrc({
1414
// Get the home directory
1515
const homeDirectory = os.homedir();
1616

17-
// // Define the path for the .npmrc file
17+
// Define the path for the .npmrc file
1818
const userNpmrcPath = path.join(homeDirectory, ".npmrc");
1919

2020
logger.info(`Writing users .npmrc to: ${userNpmrcPath}`);
2121

2222
try {
2323
// Write the content to the .npmrc file
24-
await fs.writeFile(userNpmrcPath, npmrc);
24+
// fs.appendFile will create the file if it doesn't exist
25+
await fs.appendFile(userNpmrcPath, npmrc, "utf8");
26+
logger.info("Successfully wrote .npmrc file");
2527
} catch (error) {
2628
const errorMessage = `Error writing users .npmrc to ${userNpmrcPath}: ${error instanceof Error ? error.message : ""}`;
2729
throw new Error(errorMessage);

0 commit comments

Comments
 (0)
0