refactor(npm): npmrc string check

This commit is contained in:
Rhys Arkins 2021-03-27 07:19:05 +01:00
parent e541f3ed28
commit 486decbee6

View file

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