ai-battery 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/bin/ai-battery.js +16 -2
  2. package/package.json +1 -1
package/bin/ai-battery.js CHANGED
@@ -2435,10 +2435,24 @@ async function main() {
2435
2435
  export {
2436
2436
  firstPercentValue,
2437
2437
  normalizeLimit,
2438
- percentValue
2438
+ percentValue,
2439
+ sameFilePath
2439
2440
  };
2440
2441
 
2441
- if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
2442
+ function sameFilePath(leftPath, rightPath) {
2443
+ try {
2444
+ return fs.realpathSync(leftPath) === fs.realpathSync(rightPath);
2445
+ } catch {
2446
+ return pathToFileURL(leftPath).href === pathToFileURL(rightPath).href;
2447
+ }
2448
+ }
2449
+
2450
+ function isDirectRun() {
2451
+ if (!process.argv[1]) return false;
2452
+ return sameFilePath(fileURLToPath(import.meta.url), process.argv[1]);
2453
+ }
2454
+
2455
+ if (isDirectRun()) {
2442
2456
  main().catch((error) => {
2443
2457
  console.error(`ai-battery: ${error.message}`);
2444
2458
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-battery",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Tiny terminal battery meter for local Codex and Claude Code usage.",
5
5
  "type": "module",
6
6
  "keywords": [