Skip to content

Commit

Permalink
feat(bun): update .npmrc file in bun projects
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-dahl authored Feb 12, 2025
1 parent e9caa32 commit 106ca3a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/modules/manager/bun/artifacts.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import upath from 'upath';
import is from '@sindresorhus/is';
import { GlobalConfig } from '../../../config/global';
import { TEMPORARY_ERROR } from '../../../constants/error-messages';
Expand All @@ -9,6 +10,12 @@ import {
readLocalFile,
writeLocalFile,
} from '../../../util/fs';
import {
getNpmrcContent,
resetNpmrcContent,
updateNpmrcContent,
} from '../npm/utils';
import { processHostRules } from '../npm/post-update/rules';
import type { UpdateArtifact, UpdateArtifactsResult } from '../types';

export async function updateArtifacts(
Expand Down Expand Up @@ -39,6 +46,11 @@ export async function updateArtifacts(
return null;
}

const pkgFileDir = upath.dirname(packageFileName);
const npmrcContent = await getNpmrcContent(pkgFileDir);
const { additionalNpmrcContent } = processHostRules();
await updateNpmrcContent(pkgFileDir, npmrcContent, additionalNpmrcContent);

try {
await writeLocalFile(packageFileName, newPackageFileContent);
if (isLockFileMaintenance) {
Expand All @@ -64,6 +76,8 @@ export async function updateArtifacts(
};

await exec(cmd, execOptions);
await resetNpmrcContent(pkgFileDir, npmrcContent);

const newLockFileContent = await readLocalFile(lockFileName);
if (
!newLockFileContent ||
Expand Down

0 comments on commit 106ca3a

Please sign in to comment.