|
1 | | -import {join, dirname, fromFileUrl} from '@std/path' |
2 | 1 | import {EOL} from '@std/fs' |
3 | 2 | import {parse} from '@std/semver' |
4 | 3 | import {difference} from '@std/datetime' |
5 | 4 | 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' |
10 | 6 |
|
11 | 7 | function renderAge(date?: string): string { |
12 | 8 | if (!date) return '' |
@@ -34,18 +30,16 @@ export default new ResourceCommand('version') |
34 | 30 | .example('print version information in json format', 'mzm version -o json') |
35 | 31 | .example('print version information in yaml format', 'mzm version -o json') |
36 | 32 | .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) |
42 | 35 |
|
| 36 | + const semver = parse(version_info.version) |
43 | 37 | const to_render = { |
44 | | - version: pkg_json.version |
| 38 | + version: version_info.version |
45 | 39 | , major: semver.major |
46 | 40 | , minor: semver.minor |
47 | 41 | , patch: semver.patch |
48 | | - , date: new Date(pkg_json.release_date) |
| 42 | + , date: new Date(version_info.release_date) |
49 | 43 | } |
50 | 44 |
|
51 | 45 | //@ts-ignore work around for command subclassing |
|
0 commit comments