$61 GRAYBYTE WORDPRESS FILE MANAGER $66

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/alt-nodejs19/root/usr/lib/node_modules/npm/lib/commands/

HOME
Current File : /opt/alt/alt-nodejs19/root/usr/lib/node_modules/npm/lib/commands//run-script.js
const { resolve } = require('path')
const runScript = require('@npmcli/run-script')
const { isServerPackage } = runScript
const rpj = require('read-package-json-fast')
const log = require('../utils/log-shim.js')
const didYouMean = require('../utils/did-you-mean.js')
const { isWindowsShell } = require('../utils/is-windows.js')

const cmdList = [
  'publish',
  'install',
  'uninstall',
  'test',
  'stop',
  'start',
  'restart',
  'version',
].reduce((l, p) => l.concat(['pre' + p, p, 'post' + p]), [])

const BaseCommand = require('../base-command.js')
class RunScript extends BaseCommand {
  static description = 'Run arbitrary package scripts'
  static params = [
    'workspace',
    'workspaces',
    'include-workspace-root',
    'if-present',
    'ignore-scripts',
    'foreground-scripts',
    'script-shell',
  ]

  static name = 'run-script'
  static usage = ['<command> [-- <args>]']
  static workspaces = true
  static ignoreImplicitWorkspace = false
  static isShellout = true

  async completion (opts) {
    const argv = opts.conf.argv.remain
    if (argv.length === 2) {
      // find the script name
      const json = resolve(this.npm.localPrefix, 'package.json')
      const { scripts = {} } = await rpj(json).catch(er => ({}))
      if (opts.isFish) {
        return Object.keys(scripts).map(s => `${s}\t${scripts[s].slice(0, 30)}`)
      }
      return Object.keys(scripts)
    }
  }

  async exec (args) {
    if (args.length) {
      return this.run(args)
    } else {
      return this.list(args)
    }
  }

  async execWorkspaces (args) {
    if (args.length) {
      return this.runWorkspaces(args)
    } else {
      return this.listWorkspaces(args)
    }
  }

  async run ([event, ...args], { path = this.npm.localPrefix, pkg } = {}) {
    // this || undefined is because runScript will be unhappy with the default
    // null value
    const scriptShell = this.npm.config.get('script-shell') || undefined

    pkg = pkg || (await rpj(`${path}/package.json`))
    const { scripts = {} } = pkg

    if (event === 'restart' && !scripts.restart) {
      scripts.restart = 'npm stop --if-present && npm start'
    } else if (event === 'env' && !scripts.env) {
      scripts.env = isWindowsShell ? 'SET' : 'env'
    }

    pkg.scripts = scripts

    if (
      !Object.prototype.hasOwnProperty.call(scripts, event) &&
      !(event === 'start' && (await isServerPackage(path)))
    ) {
      if (this.npm.config.get('if-present')) {
        return
      }

      const suggestions = await didYouMean(this.npm, path, event)
      throw new Error(
        `Missing script: "${event}"${suggestions}\n\nTo see a list of scripts, run:\n  npm run`
      )
    }

    // positional args only added to the main event, not pre/post
    const events = [[event, args]]
    if (!this.npm.config.get('ignore-scripts')) {
      if (scripts[`pre${event}`]) {
        events.unshift([`pre${event}`, []])
      }

      if (scripts[`post${event}`]) {
        events.push([`post${event}`, []])
      }
    }

    const opts = {
      path,
      args,
      scriptShell,
      stdio: 'inherit',
      pkg,
      banner: !this.npm.silent,
    }

    for (const [ev, evArgs] of events) {
      await runScript({
        ...opts,
        event: ev,
        args: evArgs,
      })
    }
  }

  async list (args, path) {
    path = path || this.npm.localPrefix
    const { scripts, name, _id } = await rpj(`${path}/package.json`)
    const pkgid = _id || name

    if (!scripts) {
      return []
    }

    const allScripts = Object.keys(scripts)
    if (this.npm.silent) {
      return allScripts
    }

    if (this.npm.config.get('json')) {
      this.npm.output(JSON.stringify(scripts, null, 2))
      return allScripts
    }

    if (this.npm.config.get('parseable')) {
      for (const [script, cmd] of Object.entries(scripts)) {
        this.npm.output(`${script}:${cmd}`)
      }

      return allScripts
    }

    const indent = '\n    '
    const prefix = '  '
    const cmds = []
    const runScripts = []
    for (const script of allScripts) {
      const list = cmdList.includes(script) ? cmds : runScripts
      list.push(script)
    }
    const colorize = this.npm.chalk

    if (cmds.length) {
      this.npm.output(
        `${colorize.reset(colorize.bold('Lifecycle scripts'))} included in ${colorize.green(
          pkgid
        )}:`
      )
    }

    for (const script of cmds) {
      this.npm.output(prefix + script + indent + colorize.dim(scripts[script]))
    }

    if (!cmds.length && runScripts.length) {
      this.npm.output(
        `${colorize.bold('Scripts')} available in ${colorize.green(pkgid)} via \`${colorize.blue(
          'npm run-script'
        )}\`:`
      )
    } else if (runScripts.length) {
      this.npm.output(`\navailable via \`${colorize.blue('npm run-script')}\`:`)
    }

    for (const script of runScripts) {
      this.npm.output(prefix + script + indent + colorize.dim(scripts[script]))
    }

    this.npm.output('')
    return allScripts
  }

  async runWorkspaces (args, filters) {
    const res = []
    await this.setWorkspaces()

    for (const workspacePath of this.workspacePaths) {
      const pkg = await rpj(`${workspacePath}/package.json`)
      const runResult = await this.run(args, {
        path: workspacePath,
        pkg,
      }).catch(err => {
        log.error(`Lifecycle script \`${args[0]}\` failed with error:`)
        log.error(err)
        log.error(`  in workspace: ${pkg._id || pkg.name}`)
        log.error(`  at location: ${workspacePath}`)

        const scriptMissing = err.message.startsWith('Missing script')

        // avoids exiting with error code in case there's scripts missing
        // in some workspaces since other scripts might have succeeded
        if (!scriptMissing) {
          process.exitCode = 1
        }

        return scriptMissing
      })
      res.push(runResult)
    }

    // in case **all** tests are missing, then it should exit with error code
    if (res.every(Boolean)) {
      throw new Error(`Missing script: ${args[0]}`)
    }
  }

  async listWorkspaces (args, filters) {
    await this.setWorkspaces()

    if (this.npm.silent) {
      return
    }

    if (this.npm.config.get('json')) {
      const res = {}
      for (const workspacePath of this.workspacePaths) {
        const { scripts, name } = await rpj(`${workspacePath}/package.json`)
        res[name] = { ...scripts }
      }
      this.npm.output(JSON.stringify(res, null, 2))
      return
    }

    if (this.npm.config.get('parseable')) {
      for (const workspacePath of this.workspacePaths) {
        const { scripts, name } = await rpj(`${workspacePath}/package.json`)
        for (const [script, cmd] of Object.entries(scripts || {})) {
          this.npm.output(`${name}:${script}:${cmd}`)
        }
      }
      return
    }

    for (const workspacePath of this.workspacePaths) {
      await this.list(args, workspacePath)
    }
  }
}

module.exports = RunScript

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
31 Aug 2024 8.02 AM
root / root
0755
access.js
6.079 KB
7 Dec 2023 1.07 AM
root / root
0644
adduser.js
1.318 KB
7 Dec 2023 1.07 AM
root / root
0644
audit.js
13.863 KB
7 Dec 2023 1.07 AM
root / root
0644
bugs.js
0.796 KB
7 Dec 2023 1.07 AM
root / root
0644
cache.js
7.072 KB
7 Dec 2023 1.07 AM
root / root
0644
ci.js
3.509 KB
7 Dec 2023 1.07 AM
root / root
0644
completion.js
8.734 KB
7 Dec 2023 1.07 AM
root / root
0644
config.js
10.037 KB
7 Dec 2023 1.07 AM
root / root
0644
dedupe.js
1.396 KB
7 Dec 2023 1.07 AM
root / root
0644
deprecate.js
2.029 KB
7 Dec 2023 1.07 AM
root / root
0644
diff.js
8.123 KB
7 Dec 2023 1.07 AM
root / root
0644
dist-tag.js
5.451 KB
7 Dec 2023 1.07 AM
root / root
0644
docs.js
0.437 KB
7 Dec 2023 1.07 AM
root / root
0644
doctor.js
11.512 KB
7 Dec 2023 1.07 AM
root / root
0644
edit.js
1.997 KB
7 Dec 2023 1.07 AM
root / root
0644
exec.js
2.542 KB
7 Dec 2023 1.07 AM
root / root
0644
explain.js
3.554 KB
7 Dec 2023 1.07 AM
root / root
0644
explore.js
2.305 KB
7 Dec 2023 1.07 AM
root / root
0644
find-dupes.js
0.607 KB
7 Dec 2023 1.07 AM
root / root
0644
fund.js
6.513 KB
7 Dec 2023 1.07 AM
root / root
0644
get.js
0.512 KB
7 Dec 2023 1.07 AM
root / root
0644
help-search.js
5.494 KB
7 Dec 2023 1.07 AM
root / root
0644
help.js
3.535 KB
7 Dec 2023 1.07 AM
root / root
0644
hook.js
3.77 KB
7 Dec 2023 1.07 AM
root / root
0644
init.js
6.902 KB
7 Dec 2023 1.07 AM
root / root
0644
install-ci-test.js
0.364 KB
7 Dec 2023 1.07 AM
root / root
0644
install-test.js
0.361 KB
7 Dec 2023 1.07 AM
root / root
0644
install.js
5.108 KB
7 Dec 2023 1.07 AM
root / root
0644
link.js
5.154 KB
7 Dec 2023 1.07 AM
root / root
0644
ll.js
0.229 KB
7 Dec 2023 1.07 AM
root / root
0644
login.js
1.315 KB
7 Dec 2023 1.07 AM
root / root
0644
logout.js
1.305 KB
7 Dec 2023 1.07 AM
root / root
0644
ls.js
16.729 KB
7 Dec 2023 1.07 AM
root / root
0644
org.js
4.144 KB
7 Dec 2023 1.07 AM
root / root
0644
outdated.js
8.762 KB
7 Dec 2023 1.07 AM
root / root
0644
owner.js
5.906 KB
7 Dec 2023 1.07 AM
root / root
0644
pack.js
2.373 KB
7 Dec 2023 1.07 AM
root / root
0644
ping.js
0.896 KB
7 Dec 2023 1.07 AM
root / root
0644
pkg.js
3.499 KB
7 Dec 2023 1.07 AM
root / root
0644
prefix.js
0.296 KB
7 Dec 2023 1.07 AM
root / root
0644
profile.js
11.188 KB
7 Dec 2023 1.07 AM
root / root
0644
prune.js
0.761 KB
7 Dec 2023 1.07 AM
root / root
0644
publish.js
6.503 KB
7 Dec 2023 1.07 AM
root / root
0644
query.js
2.9 KB
7 Dec 2023 1.07 AM
root / root
0644
rebuild.js
2.141 KB
7 Dec 2023 1.07 AM
root / root
0644
repo.js
1.242 KB
7 Dec 2023 1.07 AM
root / root
0644
restart.js
0.303 KB
7 Dec 2023 1.07 AM
root / root
0644
root.js
0.252 KB
7 Dec 2023 1.07 AM
root / root
0644
run-script.js
6.814 KB
7 Dec 2023 1.07 AM
root / root
0644
search.js
2.677 KB
7 Dec 2023 1.07 AM
root / root
0644
set.js
0.559 KB
7 Dec 2023 1.07 AM
root / root
0644
shrinkwrap.js
2.642 KB
7 Dec 2023 1.07 AM
root / root
0644
star.js
1.866 KB
7 Dec 2023 1.07 AM
root / root
0644
stars.js
1.027 KB
7 Dec 2023 1.07 AM
root / root
0644
start.js
0.293 KB
7 Dec 2023 1.07 AM
root / root
0644
stop.js
0.288 KB
7 Dec 2023 1.07 AM
root / root
0644
team.js
4.438 KB
7 Dec 2023 1.07 AM
root / root
0644
test.js
0.288 KB
7 Dec 2023 1.07 AM
root / root
0644
token.js
6.642 KB
7 Dec 2023 1.07 AM
root / root
0644
uninstall.js
1.506 KB
7 Dec 2023 1.07 AM
root / root
0644
unpublish.js
4.544 KB
7 Dec 2023 1.07 AM
root / root
0644
unstar.js
0.178 KB
7 Dec 2023 1.07 AM
root / root
0644
update.js
1.709 KB
7 Dec 2023 1.07 AM
root / root
0644
version.js
3.576 KB
7 Dec 2023 1.07 AM
root / root
0644
view.js
14.375 KB
7 Dec 2023 1.07 AM
root / root
0644
whoami.js
0.463 KB
7 Dec 2023 1.07 AM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF