From 58daa0336319624f5ec783806d0e8a00f4aefb24 Mon Sep 17 00:00:00 2001 From: Alex Van Camp Date: Tue, 20 Jun 2023 17:51:58 -0500 Subject: [PATCH] fix: try prepending "v" to the checkout tag when installing a bundle --- src/commands/install.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/commands/install.ts b/src/commands/install.ts index 23a305e..775e871 100644 --- a/src/commands/install.ts +++ b/src/commands/install.ts @@ -102,18 +102,28 @@ function action(repo: string, options: { dev: boolean }) { if (target) { process.stdout.write(`Checking out version ${target}... `); try { + // First try the target as-is. execSync(`git checkout ${target}`, { cwd: bundlePath, stdio: ['pipe', 'pipe', 'pipe'], }); process.stdout.write(chalk.green('done!') + os.EOL); - } catch (e) { - /* istanbul ignore next */ - process.stdout.write(chalk.red('failed!') + os.EOL); - /* istanbul ignore next */ - console.error(e.stack); - /* istanbul ignore next */ - return; + } catch (_e) { + try { + // Next try prepending `v` to the target, which may have been stripped by `semver.coerce`. + execSync(`git checkout v${target}`, { + cwd: bundlePath, + stdio: ['pipe', 'pipe', 'pipe'], + }); + process.stdout.write(chalk.green('done!') + os.EOL); + } catch (e) { + /* istanbul ignore next */ + process.stdout.write(chalk.red('failed!') + os.EOL); + /* istanbul ignore next */ + console.error(e.stack); + /* istanbul ignore next */ + return; + } } }