Compare commits

...

2 Commits

Author SHA1 Message Date
sebastienlorber d7fd239663 return early for npm upgrade command 2023-04-20 16:37:59 +02:00
Andrew Nicols 2c72a76c27 fix(core): Correct yarn upgrade command for yarn 2.x 2023-04-20 10:00:07 +08:00
1 changed files with 15 additions and 5 deletions

View File

@ -104,10 +104,20 @@ export default async function beforeCli() {
.filter((p) => p.startsWith('@docusaurus'))
.map((p) => p.concat('@latest'))
.join(' ');
const isYarnUsed = await fs.pathExists(path.resolve('yarn.lock'));
const upgradeCommand = isYarnUsed
? `yarn upgrade ${siteDocusaurusPackagesForUpdate}`
: `npm i ${siteDocusaurusPackagesForUpdate}`;
const getUpgradeCommand = async () => {
const isYarnUsed = await fs.pathExists(path.resolve('yarn.lock'));
if (!isYarnUsed) {
return `npm i ${siteDocusaurusPackagesForUpdate}`;
}
const isYarnClassicUsed = !(await fs.pathExists(
path.resolve('.yarnrc.yml'),
));
return isYarnClassicUsed
? `yarn upgrade ${siteDocusaurusPackagesForUpdate}`
: `yarn up ${siteDocusaurusPackagesForUpdate}`;
};
/** @type {import('boxen').Options} */
const boxenOptions = {
@ -124,7 +134,7 @@ export default async function beforeCli() {
)} ${logger.green(`${notifier.update.latest}`)}
To upgrade Docusaurus packages with the latest version, run the following command:
${logger.code(upgradeCommand)}`,
${logger.code(await getUpgradeCommand())}`,
boxenOptions,
);