Skip to content

Commit 51d180a

Browse files
Fix publish-npm.ts for packages with no dependencies (#6258)
1 parent e6c8108 commit 51d180a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

scripts/publish-npm.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ async function main() {
9696
// Check the package.json for 'link:' and 'file:' dependencies.
9797
const packageJson = JSON.parse(fs.readFileSync('package.json')
9898
.toString('utf8')) as {dependencies: Record<string, string>};
99-
for (let [dep, depVersion] of Object.entries(packageJson.dependencies)) {
100-
const start = depVersion.slice(0,5);
101-
if (start === 'link:' || start === 'file:') {
102-
throw new Error(`${pkg} has a '${start}' dependency on ${dep}. `
103-
+ 'Refusing to publish.');
99+
if (packageJson.dependencies) {
100+
for (let [dep, depVersion] of Object.entries(packageJson.dependencies)) {
101+
const start = depVersion.slice(0,5);
102+
if (start === 'link:' || start === 'file:') {
103+
throw new Error(`${pkg} has a '${start}' dependency on ${dep}. `
104+
+ 'Refusing to publish.');
105+
}
104106
}
105107
}
106108

0 commit comments

Comments
 (0)