File size: 1,028 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | const cp = require( 'child_process' );
const { promisify } = require( 'util' );
const { getNpmRc } = require( '../lib' );
const exec = promisify( cp.exec );
module.exports = {
title: 'npm cache',
group: 'Node.js',
description: 'Sets npm_config_cache, used by many packages to store downloaded binaries.',
test: async ( { pass, fail, ignore } ) => {
if ( process.platform !== 'darwin' && process.platform !== 'linux' ) {
ignore( 'This evaluation only works in OSX or Linux' );
return;
}
const yarnPath = process.env.npm_config_yarn_path || 'yarn';
const { stdout } = await exec( `${ yarnPath } run -s env` );
const env = JSON.parse( stdout );
if ( ! env.npm_config_cache ) {
fail( 'npm_config_cache is not set' );
return;
}
pass();
},
fix: async () => {
const yarnPath = process.env.npm_config_yarn_path || 'yarn';
const { stdout } = await exec( `${ yarnPath } cache dir` );
const yarnCachePath = stdout.trim();
return `Add \`cache=${ yarnCachePath }\` to ${ getNpmRc() }`;
},
};
|