File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -2,18 +2,29 @@ const fs = require('fs');
22const { defineConfig} = require ( `@yarnpkg/types` ) ;
33const { logError} = require ( './scripts/utils' ) ;
44
5- function checkYarnLock ( ) {
6- const yarnLock = fs . readFileSync ( './yarn.lock' , 'utf8' ) ;
7- const matches = yarnLock . match ( / n p m .d e v / ) ;
5+ const UNWANTED_DEPENDENCIES = 'npm.dev' ;
6+
7+ function checkUnwantedDependencies ( file ) {
8+ const fileContent = fs . readFileSync ( file , 'utf8' ) ;
9+ const matches = fileContent . match ( new RegExp ( `${ UNWANTED_DEPENDENCIES } ` , 'g' ) ) ;
810
911 if ( matches !== null ) {
10- logError ( 'Yarn lock contains unwanted dependencies' ) ;
12+ logError ( 'Unwanted dependencies found in ' + file ) ;
1113 process . exit ( 1 ) ;
1214 }
1315}
1416
17+ function checkYarnLock ( ) {
18+ checkUnwantedDependencies ( './yarn.lock' ) ;
19+ }
20+
21+ function checkYarnRc ( ) {
22+ checkUnwantedDependencies ( './.yarnrc.yml' ) ;
23+ }
24+
1525module . exports = defineConfig ( {
1626 constraints : async ( ) => {
1727 checkYarnLock ( ) ;
28+ checkYarnRc ( ) ;
1829 }
1930} ) ;
You can’t perform that action at this time.
0 commit comments