Skip to content

Commit fe32170

Browse files
committed
chore(command-version): use release module to pull version info
replaces the inline handling of the version determination with the release module which contains an async and sync function to pull the release version info + date
1 parent 1171757 commit fe32170

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

@mzm/command-version/mod.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import {join, dirname, fromFileUrl} from '@std/path'
21
import {EOL} from '@std/fs'
32
import {parse} from '@std/semver'
43
import {difference} from '@std/datetime'
54
import {ResourceCommand} from '@mzm/core'
6-
7-
const current_directory = dirname(fromFileUrl(import.meta.url))
8-
const project_root = join(current_directory, '..', '..')
9-
const pkg_file = join(project_root, 'release.info')
5+
import {info} from '@mzm/core/release'
106

117
function renderAge(date?: string): string {
128
if (!date) return ''
@@ -34,18 +30,16 @@ export default new ResourceCommand('version')
3430
.example('print version information in json format', 'mzm version -o json')
3531
.example('print version information in yaml format', 'mzm version -o json')
3632
.action(async function(options: any) {
37-
const pkg_text = await Deno.readTextFile(pkg_file)
38-
const pkg_json = JSON.parse(pkg_text)
39-
const semver = parse(pkg_json.version)
40-
41-
if (options.quiet) return console.log(pkg_json.version)
33+
const version_info = await info()
34+
if (options.quiet) return console.log(version_info.version)
4235

36+
const semver = parse(version_info.version)
4337
const to_render = {
44-
version: pkg_json.version
38+
version: version_info.version
4539
, major: semver.major
4640
, minor: semver.minor
4741
, patch: semver.patch
48-
, date: new Date(pkg_json.release_date)
42+
, date: new Date(version_info.release_date)
4943
}
5044

5145
//@ts-ignore work around for command subclassing

0 commit comments

Comments
 (0)