[fs-detectors] check turbo versions to allow for tags like "latest" (#9790)

When a project depends on `turbo` at version `latest`, this code was breaking because `latest` is not a valid range for `semver.intersects`.
This commit is contained in:
Sean Massa
2023-04-11 16:22:41 -05:00
committed by GitHub
parent 43a57a3a60
commit e302631ded
5 changed files with 30 additions and 1 deletions

View File

@@ -22,6 +22,18 @@ export class MissingBuildTarget extends Error {
}
}
function supportsRootCommand(turboSemVer: string | undefined) {
if (!turboSemVer) {
return false;
}
if (!semver.validRange(turboSemVer)) {
return false;
}
return !semver.intersects(turboSemVer, '<1.8.0');
}
type MonorepoDefaultSettings = {
buildCommand?: string | null;
installCommand?: string | null;
@@ -91,7 +103,7 @@ export async function getMonorepoDefaultSettings(
let buildCommand = null;
if (projectPath) {
if (turboSemVer && !semver.intersects(turboSemVer, '<1.8.0')) {
if (supportsRootCommand(turboSemVer)) {
buildCommand = `turbo run build`;
} else {
// We don't know for sure if the local `turbo` supports inference.