MCPcopy
hub / github.com/ampproject/amphtml / updateSubpackages

Function updateSubpackages

build-system/common/update-packages.js:232–250  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

230 * @param {boolean=} skipNpmChecks
231 */
232function 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
252module.exports = {
253 updatePackages,

Callers 3

ensureUpdatedPackagesFunction · 0.85
storybookFunction · 0.85

Calls 8

cyanFunction · 0.85
isCiBuildFunction · 0.85
redFunction · 0.85
isPullRequestBuildFunction · 0.85
runNpmChecksFunction · 0.85
syncMethod · 0.80
logFunction · 0.70
getOutputFunction · 0.70

Tested by

no test coverage detected