@builtbyecho/public-api-finder 0.5.1 → 0.5.2

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/package.json +1 -1
  2. package/src/cli.js +12 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builtbyecho/public-api-finder",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Find free/public APIs for agents and prototypes.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
+ import { realpathSync } from 'node:fs';
2
3
  import { mkdir, readFile, stat, writeFile } from 'node:fs/promises';
3
4
  import { homedir } from 'node:os';
4
5
  import { dirname, join } from 'node:path';
5
- import { pathToFileURL } from 'node:url';
6
+ import { fileURLToPath } from 'node:url';
6
7
 
7
8
  const SOURCES = {
8
9
  publicApiLists: 'https://public-api-lists.github.io/public-api-lists/api/all.json',
@@ -860,7 +861,16 @@ async function main() {
860
861
  return 0;
861
862
  }
862
863
 
863
- if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
864
+ function isDirectRun() {
865
+ if (!process.argv[1]) return false;
866
+ try {
867
+ return realpathSync(process.argv[1]) === fileURLToPath(import.meta.url);
868
+ } catch {
869
+ return false;
870
+ }
871
+ }
872
+
873
+ if (isDirectRun()) {
864
874
  main().then(code => process.exitCode = code).catch(err => {
865
875
  console.error(`public-api-finder: ${err.message}`);
866
876
  process.exitCode = 1;