mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 16:59:06 +02:00
fix: cli upgrade helper fail when no package.dependencies
(#5204)
* Fix handling of empty `dependencies` section. In Flipper, https://github.com/facebook/flipper/blob/master/website/package.json, all our dependencies live in `devDependecies` of our `package.json`. As a result `dependencies` is not set, causing a crash when running `yarn start`: ``` /Users/mweststrate/fbsource/xplat/sonar/website/node_modules/@docusaurus/core/bin/docusaurus.js:50 const siteDocusaurusPackagesForUpdate = Object.keys(sitePkg.dependencies) ^ TypeError: Cannot convert undefined or null to object at Function.keys (<anonymous>) at Object.<anonymous> (/Users/mweststrate/fbsource/xplat/sonar/website/node_modules/@docusaurus/core/bin/docusaurus.js:50:50) at Module._compile (internal/modules/cjs/loader.js:955:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10) at Module.load (internal/modules/cjs/loader.js:811:32) at Function.Module._load (internal/modules/cjs/loader.js:723:14) at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) at internal/main/run_main_module.js:17:11 error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. ``` Setting `"dependencies": {}`, works as work around, but this patch fixes the crash, and makes sure the deps are upgraded as well if they live in `devDependencies` instead of `dependencies`. * formatting fix
This commit is contained in:
parent
4d06f26c1f
commit
ddc0f46b73
1 changed files with 4 additions and 1 deletions
|
@ -57,7 +57,10 @@ if (notifier.update && notifier.update.current !== notifier.update.latest) {
|
|||
|
||||
// eslint-disable-next-line import/no-dynamic-require, global-require
|
||||
const sitePkg = require(path.resolve(process.cwd(), 'package.json'));
|
||||
const siteDocusaurusPackagesForUpdate = Object.keys(sitePkg.dependencies)
|
||||
const siteDocusaurusPackagesForUpdate = Object.keys({
|
||||
...sitePkg.dependencies,
|
||||
...sitePkg.devDependencies,
|
||||
})
|
||||
.filter((p) => p.startsWith('@docusaurus'))
|
||||
.map((p) => p.concat('@latest'))
|
||||
.join(' ');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue