fix(npm): is.string check for npmrc

This commit is contained in:
Rhys Arkins 2021-04-01 18:09:36 +02:00
parent 95bf948020
commit 47eb1324fb
3 changed files with 4 additions and 3 deletions

View file

@ -1,3 +1,4 @@
import is from '@sindresorhus/is';
import type { GetReleasesConfig, ReleaseResult } from '../types';
import { getDependency } from './get';
import { setNpmrc } from './npmrc';
@ -6,7 +7,7 @@ export async function getReleases({
lookupName,
npmrc,
}: GetReleasesConfig): Promise<ReleaseResult | null> {
if (npmrc) {
if (is.string(npmrc)) {
setNpmrc(npmrc);
}
const res = await getDependency(lookupName);

View file

@ -106,7 +106,7 @@ export async function extractPackageFile(
logger.debug('Stripping package-lock setting from npmrc');
npmrc = npmrc.replace(/(^|\n)package-lock.*?(\n|$)/g, '\n');
}
if (npmrc) {
if (is.string(npmrc)) {
if (npmrc.includes('=${') && getAdminConfig().trustLevel !== 'high') {
logger.debug('Discarding .npmrc file with variables');
ignoreNpmrcFile = true;

View file

@ -138,7 +138,7 @@ export async function writeExistingFiles(
);
const npmrc: string = packageFile.npmrc || config.npmrc;
const npmrcFilename = upath.join(basedir, '.npmrc');
if (npmrc) {
if (is.string(npmrc)) {
try {
await outputFile(npmrcFilename, `${npmrc}\n`);
} catch (err) /* istanbul ignore next */ {