@hangox/mg-cli 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.5
package/dist/cli.js CHANGED
@@ -766,13 +766,26 @@ function getVersion() {
766
766
  try {
767
767
  const currentFile = fileURLToPath(import.meta.url);
768
768
  const currentDir = dirname3(currentFile);
769
- const possiblePaths = [
769
+ const versionFilePaths = [
770
+ join2(currentDir, "..", "VERSION"),
771
+ // dist/xxx.js -> ../VERSION
772
+ join2(currentDir, "..", "..", "VERSION")
773
+ // src/shared/version.ts -> ../../VERSION
774
+ ];
775
+ for (const versionFilePath of versionFilePaths) {
776
+ if (existsSync3(versionFilePath)) {
777
+ const version = readFileSync2(versionFilePath, "utf-8").trim();
778
+ if (version) {
779
+ cachedVersion = version;
780
+ return cachedVersion;
781
+ }
782
+ }
783
+ }
784
+ const packageJsonPaths = [
770
785
  join2(currentDir, "..", "package.json"),
771
- // dist/xxx.js -> ../package.json
772
786
  join2(currentDir, "..", "..", "package.json")
773
- // src/shared/version.ts -> ../../package.json
774
787
  ];
775
- for (const packageJsonPath of possiblePaths) {
788
+ for (const packageJsonPath of packageJsonPaths) {
776
789
  if (existsSync3(packageJsonPath)) {
777
790
  const packageJson = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
778
791
  if (packageJson.name === "@hangox/mg-cli") {