export async function getVersionFromFullFile()

in packages/autocomplete-parser/src/loadHelpers.ts [154:190]


export async function getVersionFromFullFile(
  specData: SpecFileImport,
  name: string,
) {
  // if the default export is a function it is a versioned spec
  if (typeof specData.default === "function") {
    try {
      const storageKey = `cliVersion-${name}`;
      const version = getCachedCLIVersion(storageKey);
      if (!isInDevMode() && version !== null) {
        return version;
      }

      if ("getVersionCommand" in specData && specData.getVersionCommand) {
        const newVersion = await specData.getVersionCommand(executeCommand);
        cachedCLIVersions[storageKey] = newVersion;
        return newVersion;
      }

      const newVersion = semver.clean(
        (
          await executeCommand({
            command: name,
            args: ["--version"],
          })
        ).stdout,
      );
      if (newVersion) {
        cachedCLIVersions[storageKey] = newVersion;
        return newVersion;
      }
    } catch {
      /**/
    }
  }
  return undefined;
}