@amaster.ai/runtime-cli 1.1.12 → 1.1.13

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.cjs CHANGED
@@ -3,6 +3,7 @@
3
3
  var fs = require('fs');
4
4
  var path = require('path');
5
5
  var os = require('os');
6
+ var url = require('url');
6
7
  var commander = require('commander');
7
8
  var chalk3 = require('chalk');
8
9
  var client = require('@amaster.ai/client');
@@ -3193,8 +3194,17 @@ s3Cmd.command("metadata <key>").description("Get file metadata").option("--app <
3193
3194
  format: options.format
3194
3195
  });
3195
3196
  });
3196
- var isMainModule = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) === new URL(process.argv[1] || "", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).href || (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)).endsWith(process.argv[1] || "") || process.argv[1]?.includes("cli.js") || false;
3197
- if (isMainModule) {
3197
+ function isDirectCliExecution(entryArg = process.argv[1]) {
3198
+ if (!entryArg) {
3199
+ return false;
3200
+ }
3201
+ try {
3202
+ return fs.realpathSync(entryArg) === fs.realpathSync(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
3203
+ } catch {
3204
+ return false;
3205
+ }
3206
+ }
3207
+ if (isDirectCliExecution()) {
3198
3208
  program.parseAsync(process.argv).then(
3199
3209
  () => process.exit(0),
3200
3210
  (err) => {