HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/pwa.sports-crowd.com/node_modules/.bin/get-pkg-repo
#!/usr/bin/env node

'use strict';

const fs = require(`fs`);
const getPkgRepo = require(`../`);
const through = require(`through2`);
const util = require(`util`);

const yargs = require('yargs/yargs')(process.argv.slice(2))
  .usage(
    '\nPractice writing repository URL or validate the repository in a package.json file. If used without specifying a package.json file path, you will enter an interactive shell. Otherwise, the repository info in package.json is printed.'
  )
  .scriptName('get-pkg-repo')
  .command('$0')
  .command('<path> [<path> ...]')
  .example('get-pkg-repo')
  .example('get-pkg-repo package.json')
  .example('cat package.json | get-pkg-repo')
  .help().argv;

const input = yargs._;

if (process.stdin.isTTY) {
  if (input.length > 0) {
    input.forEach(path => {
      let repo;
      fs.readFile(path, 'utf8', (err, data) => {
        if (err) {
          console.error(err);
          return;
        }

        try {
          repo = getPkgRepo(JSON.parse(data));
          console.log(repo);
        } catch (e) {
          console.error(`${path}: ${e.toString()}`);
        }
      });
    });
  } else {
    process.stdin
      .pipe(
        through.obj((chunk, enc, cb) => {
          let repo;
          const pkgData = {
            repository: chunk.toString(),
          };

          try {
            repo = getPkgRepo(pkgData);
            cb(null, util.format(repo) + '\n');
          } catch (e) {
            console.error(e.toString());
            cb();
          }
        })
      )
      .pipe(process.stdout);
  }
} else {
  process.stdin
    .pipe(
      through.obj((chunk, enc, cb) => {
        let repo;
        try {
          repo = getPkgRepo(JSON.parse(chunk.toString()));
        } catch (e) {
          console.error(e.toString());
          process.exit(1);
        }
        cb(null, util.format(repo) + '\n');
      })
    )
    .pipe(process.stdout);
}