Files
renovate/lib/modules/manager/npm/detect.ts
Michael Kriese 6804768a1a feat(npm): support pnpm workspace file overrides (#42247)
* feat(npm): support pnpm workspace file overrides

* chore: fix comment

* refactor: use types

* feat(npm/pnpm): update overrides in workspace file

* test: fix test

* chore: fix coverage
2026-04-08 12:01:31 +00:00

25 lines
865 B
TypeScript

import os from 'node:os';
import { isNonEmptyString } from '@sindresorhus/is';
import upath from 'upath';
import { logger } from '../../../logger/index.ts';
import { readSystemFile } from '../../../util/fs/index.ts';
import type { GlobalManagerConfig } from '../types.ts';
export async function detectGlobalConfig(): Promise<GlobalManagerConfig> {
const res: GlobalManagerConfig = {};
const homedir = os.homedir();
const npmrcFileName = upath.join(homedir, '.npmrc');
try {
const npmrc = await readSystemFile(npmrcFileName, 'utf8');
// v8 ignore else -- TODO: add test #40625
if (isNonEmptyString(npmrc)) {
res.npmrc = npmrc;
res.npmrcMerge = true;
logger.debug(`Detected ${npmrcFileName} and adding it to global config`);
}
} catch {
logger.warn({ npmrcFileName }, 'Error reading .npmrc file');
}
return res;
}