File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
projects/npm-tools/packages/npm-scripts/src/scripts/check Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ const {SpawnError} = require('../../utils/spawnSync');
88const checkConfigFileNames = require ( './preflight/checkConfigFileNames' ) ;
99const checkPackageJSONFiles = require ( './preflight/checkPackageJSONFiles' ) ;
1010const checkTypeScriptTypeArtifacts = require ( './preflight/checkTypeScriptTypeArtifacts' ) ;
11+ const checkYarnLock = require ( './preflight/checkYarnLock' ) ;
1112
1213/**
1314 * Runs the "preflight" checks (basically everything that is not already covered
@@ -18,6 +19,7 @@ async function preflight() {
1819 ...checkConfigFileNames ( ) ,
1920 ...checkPackageJSONFiles ( ) ,
2021 ...( await checkTypeScriptTypeArtifacts ( ) ) ,
22+ ...checkYarnLock ( ) ,
2123 ] ;
2224
2325 if ( errors . length ) {
Original file line number Diff line number Diff line change 1+ /**
2+ * SPDX-FileCopyrightText: © 2019 Liferay, Inc. <https://liferay.com>
3+ * SPDX-License-Identifier: BSD-3-Clause
4+ */
5+
6+ const { readFileSync} = require ( 'fs' ) ;
7+ const path = require ( 'path' ) ;
8+
9+ const findRoot = require ( '../../../utils/findRoot' ) ;
10+
11+ const LOCAL_REGISTRY_REGEX = / ^ \s + r e s o l v e d \s " .* ( l o c a l h o s t | 1 2 7 .0 .0 .1 ) .* $ / gm;
12+
13+ function checkYarnLock ( ) {
14+ const yarnLock = path . join ( findRoot ( ) , 'yarn.lock' ) ;
15+
16+ if ( ! yarnLock ) {
17+ return [ ] ;
18+ }
19+
20+ const yarnLockContent = readFileSync ( yarnLock , 'utf8' ) ;
21+
22+ return LOCAL_REGISTRY_REGEX . test ( yarnLockContent )
23+ ? [ 'Error: `yarn.lock` contains references to local npm registry.' ]
24+ : [ ] ;
25+ }
26+
27+ module . exports = checkYarnLock ;
You can’t perform that action at this time.
0 commit comments