/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
tools/validation/validate-package-lock.cjs
39 строк
1 KB
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
#!/usr/bin/env node 'use strict'; // This script validates `package-lock.json` to avoid the introduction of an // erroneous `"resolved": false` value. It appears to be related to an upstream // unresolved issue with NPM. If the upstream issue is resolved, this script // should no longer be necessary. // // See: https://github.com/npm/cli/issues/1138 const path = require( 'path' ); const { readFileSync } = require( 'fs' ); const { red, yellow } = require( 'chalk' ); const packageLockPath = path.resolve( __dirname, '../../package-lock.json' ); const packageLock = JSON.parse( readFileSync( packageLockPath, 'utf8' ) ); const dependencies = /** @type {Array<[string, any]>} */ ( Object.entries( packageLock.packages ) ); for ( const [ name, dependency ] of dependencies ) { if ( dependency.resolved === false ) { console.log( `Invalid resolved dependency in package-lock.json. ${ red( JSON.stringify( { [ name ]: dependency }, null, '\t' ) ) } To fix, try removing the node_modules directory and reverting package-lock.json, then run ${ yellow( 'npm install' ) }. ` ); process.exit( 1 ); } if ( dependency.dependencies ) { dependencies.push( ...Object.entries( dependency.dependencies ) ); } }