mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-27 07:50:47 +00:00
6804768a1a
* 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
25 lines
865 B
TypeScript
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;
|
|
}
|