Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bin/beacon.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ const fs = require('fs');
const os = require('os');
const path = require('path');

const VERSION = '1.0.0';
const PKG_ROOT = path.join(__dirname, '..');
let VERSION = '1.0.0';
try {
const pkg = require(path.join(PKG_ROOT, 'package.json'));
if (pkg && pkg.version) VERSION = pkg.version;
} catch (_) {}

const INSTALL_DIR = path.join(os.homedir(), '.beacon', 'npm');
const VENV_DIR = path.join(INSTALL_DIR, 'venv');
Expand Down
23 changes: 23 additions & 0 deletions tests/test_npm_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import json
import os
import subprocess
import unittest

class TestNpmWrapper(unittest.TestCase):
def test_version_matches_package_json(self):
repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
pkg_json_path = os.path.join(repo_root, "package.json")
beacon_js_path = os.path.join(repo_root, "bin", "beacon.js")

with open(pkg_json_path, "r", encoding="utf-8") as f:
pkg_data = json.load(f)
expected_version = pkg_data.get("version")

res = subprocess.run(
["node", beacon_js_path, "--version"],
capture_output=True, text=True, check=True
)
self.assertEqual(res.stdout.strip(), expected_version)

if __name__ == "__main__":
unittest.main()
Loading