Skip to content

Commit e144b39

Browse files
authored
Check yarnrc for unwanted dep (#3855)
1 parent 37c411f commit e144b39

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

yarn.config.cjs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,29 @@ const fs = require('fs');
22
const {defineConfig} = require(`@yarnpkg/types`);
33
const {logError} = require('./scripts/utils');
44

5-
function checkYarnLock() {
6-
const yarnLock = fs.readFileSync('./yarn.lock', 'utf8');
7-
const matches = yarnLock.match(/npm.dev/);
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+
1525
module.exports = defineConfig({
1626
constraints: async () => {
1727
checkYarnLock();
28+
checkYarnRc();
1829
}
1930
});

0 commit comments

Comments
 (0)