diff --git a/src/command/start.ts b/src/command/start.ts index a94a769..d42fac2 100644 --- a/src/command/start.ts +++ b/src/command/start.ts @@ -11,7 +11,7 @@ import { import { waitForBlockchain, waitForQueen, waitForWorkers } from '../utils/wait' import ora from 'ora' import { VerbosityLevel } from './root-command/logging' -import { findBeeVersion } from '../utils/config-sources' +import { findBeeVersion, stripCommit } from '../utils/config-sources' const DEFAULT_REPO = 'ethersphere' @@ -85,6 +85,8 @@ export class Start extends RootCommand implements LeafCommand { this.console.log(`Spinning up cluster with Bee version ${this.beeVersion}.`) } + this.beeVersion = stripCommit(this.beeVersion) + const dockerOptions = await this.buildDockerOptions() const docker = new Docker(this.console, this.envPrefix, this.imagePrefix, this.repo) const status = await docker.getAllStatus() diff --git a/src/utils/config-sources.ts b/src/utils/config-sources.ts index d1dfefb..68a12d5 100644 --- a/src/utils/config-sources.ts +++ b/src/utils/config-sources.ts @@ -1,6 +1,17 @@ import { readFile } from 'fs/promises' import * as path from 'path' +const VERSION_REGEX = /^\d\.\d\.\d(-\w+)+$/ + +export function stripCommit(version: string): string { + if (!VERSION_REGEX.test(version)) { + throw new Error('The version does not have expected format!') + } + + // If the version contains commit ==> hash remove it + return version.replace(/(-\w+)+$/g, '') +} + async function searchPackageJson(): Promise { const expectedPath = path.join(process.cwd(), 'package.json') const pkgJson = JSON.parse(await readFile(expectedPath, { encoding: 'utf8' }))