Skip to content

Commit 362c6d5

Browse files
author
Nikhilesh Jasuja
committed
Release 0.1.1
1 parent cb376fc commit 362c6d5

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Semantic Versioning.
77

88
## [Unreleased]
99

10+
## [0.1.1] - 2026-02-02
11+
12+
- CLI --version now reports the package version (Composer or VERSION file).
13+
1014
## [0.1.0] - 2025-01-13
1115

1216
Initial release.

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.1

bin/justhtml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,29 @@ if (file_exists($autoload)) {
3737
use JustHTML\JustHTML;
3838
use JustHTML\SelectorError;
3939

40+
function resolve_version(string $root): string
41+
{
42+
if (class_exists(\Composer\InstalledVersions::class)
43+
&& method_exists(\Composer\InstalledVersions::class, 'isInstalled')
44+
&& \Composer\InstalledVersions::isInstalled('diffen/justhtml')
45+
) {
46+
$pretty = \Composer\InstalledVersions::getPrettyVersion('diffen/justhtml');
47+
if (is_string($pretty) && $pretty !== '') {
48+
return preg_replace('/^v(?=\\d)/', '', $pretty);
49+
}
50+
}
51+
52+
$versionFile = $root . '/VERSION';
53+
if (is_file($versionFile)) {
54+
$version = trim((string) file_get_contents($versionFile));
55+
if ($version !== '') {
56+
return $version;
57+
}
58+
}
59+
60+
return 'dev';
61+
}
62+
4063
function print_usage(int $code): void
4164
{
4265
$usage = <<<TEXT
@@ -75,7 +98,8 @@ for ($i = 1; $i < $argc; $i++) {
7598
}
7699

77100
if ($arg === '--version') {
78-
fwrite(STDOUT, "justhtml dev\n");
101+
$version = resolve_version($root);
102+
fwrite(STDOUT, "justhtml {$version}\n");
79103
exit(0);
80104
}
81105

0 commit comments

Comments
 (0)