@amaster.ai/runtime-cli 1.1.11 → 1.1.13-beta.0

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/index.js CHANGED
@@ -1,6 +1,7 @@
1
- import { existsSync, rmSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
1
+ import { existsSync, rmSync, mkdirSync, readFileSync, writeFileSync, realpathSync } from 'fs';
2
2
  import { join, resolve, basename } from 'path';
3
3
  import { homedir } from 'os';
4
+ import { fileURLToPath } from 'url';
4
5
  import { Command, Option } from 'commander';
5
6
  import chalk3 from 'chalk';
6
7
  import { createClient } from '@amaster.ai/client';
@@ -3184,8 +3185,17 @@ s3Cmd.command("metadata <key>").description("Get file metadata").option("--app <
3184
3185
  format: options.format
3185
3186
  });
3186
3187
  });
3187
- var isMainModule = import.meta.url === new URL(process.argv[1] || "", import.meta.url).href || import.meta.url.endsWith(process.argv[1] || "") || process.argv[1]?.includes("cli.js") || false;
3188
- if (isMainModule) {
3188
+ function isDirectCliExecution(entryArg = process.argv[1]) {
3189
+ if (!entryArg) {
3190
+ return false;
3191
+ }
3192
+ try {
3193
+ return realpathSync(entryArg) === realpathSync(fileURLToPath(import.meta.url));
3194
+ } catch {
3195
+ return false;
3196
+ }
3197
+ }
3198
+ if (isDirectCliExecution()) {
3189
3199
  program.parseAsync(process.argv).then(
3190
3200
  () => process.exit(0),
3191
3201
  (err) => {