Skip to content

Commit ab6bd71

Browse files
committed
fix script
1 parent fa412bd commit ab6bd71

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

scripts/check_changeset.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
import { resolve } from 'path';
19+
import { existsSync } from 'fs';
1920
import chalk from 'chalk';
2021
import simpleGit from 'simple-git/promise';
2122
import fs from 'mz/fs';
@@ -43,11 +44,15 @@ async function getDiffData(): Promise<{
4344
// Check for changed files inside package dirs.
4445
const pkgMatch = filename.match('^(packages(-exp)?/[a-zA-Z0-9-]+)/.*');
4546
if (pkgMatch && pkgMatch[1]) {
46-
const changedPackage = require(resolve(
47-
root,
48-
pkgMatch[1],
49-
'package.json'
50-
));
47+
// skip packages without package.json
48+
// It could happen when we rename a package or remove a package from the repo
49+
const pkgJsonPath = resolve(root, pkgMatch[1], 'package.json');
50+
51+
if (!existsSync(pkgJsonPath)) {
52+
continue;
53+
}
54+
55+
const changedPackage = require(pkgJsonPath);
5156
if (changedPackage) {
5257
// Add the package itself.
5358
changedPackages.add(changedPackage.name);

0 commit comments

Comments
 (0)