* This function updates the packages in a given task directory. * * 1. During CI, do a clean install. * 2. During local development, do an incremental install if necessary. * 3. Since script output is noisy, capture and print the stderr if needed. * 4. During CI, if not skipped, ensure package
(dir, skipNpmChecks = false)
| 230 | * @param {boolean=} skipNpmChecks |
| 231 | */ |
| 232 | function updateSubpackages(dir, skipNpmChecks = false) { |
| 233 | const results = checkDependencies.sync({packageDir: dir}); |
| 234 | const relativeDir = path.relative(process.cwd(), dir); |
| 235 | if (results.depsWereOk) { |
| 236 | const nodeModulesDir = path.join(relativeDir, 'node_modules'); |
| 237 | log('All packages in', cyan(nodeModulesDir), 'are up to date.'); |
| 238 | } else { |
| 239 | const installCmd = isCiBuild() ? 'npm ci' : 'npm install'; |
| 240 | log('Running', cyan(installCmd), 'in', cyan(relativeDir) + '...'); |
| 241 | const output = getOutput(`${installCmd} --prefix ${dir}`); |
| 242 | if (output.status !== 0) { |
| 243 | log(red('ERROR:'), output.stderr); |
| 244 | throw new Error('Installation failed'); |
| 245 | } |
| 246 | } |
| 247 | if (isPullRequestBuild() && !skipNpmChecks) { |
| 248 | runNpmChecks(dir); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | module.exports = { |
| 253 | updatePackages, |
no test coverage detected