From 7c2fd58d5167c525fe65968d882c88c337e26c2b Mon Sep 17 00:00:00 2001 From: Matthew Soulanille Date: Tue, 22 Mar 2022 13:05:44 -0700 Subject: [PATCH] Fix publish-npm.ts for packages with no dependencies --- scripts/publish-npm.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/publish-npm.ts b/scripts/publish-npm.ts index f85871fade2..3e618a126aa 100755 --- a/scripts/publish-npm.ts +++ b/scripts/publish-npm.ts @@ -96,11 +96,13 @@ async function main() { // Check the package.json for 'link:' and 'file:' dependencies. const packageJson = JSON.parse(fs.readFileSync('package.json') .toString('utf8')) as {dependencies: Record}; - for (let [dep, depVersion] of Object.entries(packageJson.dependencies)) { - const start = depVersion.slice(0,5); - if (start === 'link:' || start === 'file:') { - throw new Error(`${pkg} has a '${start}' dependency on ${dep}. ` - + 'Refusing to publish.'); + if (packageJson.dependencies) { + for (let [dep, depVersion] of Object.entries(packageJson.dependencies)) { + const start = depVersion.slice(0,5); + if (start === 'link:' || start === 'file:') { + throw new Error(`${pkg} has a '${start}' dependency on ${dep}. ` + + 'Refusing to publish.'); + } } }