@sbroenne/dvq 0.1.1 → 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.
package/dist/cli.d.ts CHANGED
@@ -2,3 +2,4 @@
2
2
  import { Command } from 'commander';
3
3
  export declare function createProgram(version?: string): Command;
4
4
  export declare function runCli(argv?: string[]): Promise<void>;
5
+ export declare function isCliEntrypoint(metaUrl: string, argv?: readonly string[]): boolean;
package/dist/cli.js CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { fileURLToPath } from 'node:url';
2
+ import { realpathSync } from 'node:fs';
3
3
  import { createRequire } from 'node:module';
4
+ import { resolve } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
4
6
  import { Command } from 'commander';
5
7
  import { MAX_PAGES, buildUrl, fetchOData, getDataverseUrl, getToken, queryAll, readQueryFile, readStdin, } from './lib.js';
6
8
  const require = createRequire(import.meta.url);
@@ -63,10 +65,14 @@ export function createProgram(version = VERSION) {
63
65
  export async function runCli(argv = process.argv.slice(2)) {
64
66
  await createProgram().parseAsync(argv, { from: 'user' });
65
67
  }
66
- const isEntrypoint = process.argv[1]
67
- ? fileURLToPath(import.meta.url) === process.argv[1]
68
- : false;
69
- if (isEntrypoint) {
68
+ export function isCliEntrypoint(metaUrl, argv = process.argv) {
69
+ const entrypoint = argv[1];
70
+ if (!entrypoint) {
71
+ return false;
72
+ }
73
+ return realpathSync(fileURLToPath(metaUrl)) === realpathSync(resolve(entrypoint));
74
+ }
75
+ if (import.meta.main ?? isCliEntrypoint(import.meta.url)) {
70
76
  runCli().catch((error) => {
71
77
  const message = error instanceof Error ? error.message : String(error);
72
78
  console.error(message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sbroenne/dvq",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "CLI for querying Dataverse OData endpoints with Azure CLI credentials",
5
5
  "type": "module",
6
6
  "bin": {