( packageJsonPath?: string, usePrefixedMajorVersion?: boolean, cwd = process.cwd(), )
| 211 | * @param cwd Current working directory |
| 212 | */ |
| 213 | export async function findDeployVersion( |
| 214 | packageJsonPath?: string, |
| 215 | usePrefixedMajorVersion?: boolean, |
| 216 | cwd = process.cwd(), |
| 217 | ): Promise<string> { |
| 218 | const {pkg} = await readPackageJson(packageJsonPath ? path.dirname(packageJsonPath) : cwd, true); |
| 219 | const version = pkg.version; |
| 220 | if (!version) { |
| 221 | throw new DocutilsError('No "version" field found in package.json; please add one or specify a version to deploy'); |
| 222 | } |
| 223 | |
| 224 | // If a minor version can be extracted, use MAJOR.MINOR as the deploy version, otherwise use MAJOR. |
| 225 | // If usePrefixedMajorVersion is true, always use vMAJOR |
| 226 | const versionParts = version.split('.'); |
| 227 | if (versionParts.length === 1) { |
| 228 | return usePrefixedMajorVersion ? `v${version}` : version; |
| 229 | } |
| 230 | return usePrefixedMajorVersion ? `v${versionParts[0]}` : `${versionParts[0]}.${versionParts[1]}`; |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * Runs `mike serve` |
no outgoing calls
no test coverage detected