Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (opts.ifPresent) return
throw new PnpmError('NO_SCRIPT', `Missing script: ${scriptName}`)
}
const lifecycleOpts = {
depPath: dir,
extraBinPaths: opts.extraBinPaths,
pkgRoot: dir,
rawConfig: opts.rawConfig,
rootNodeModulesDir: await realNodeModulesDir(dir),
stdio: 'inherit',
unsafePerm: true, // when running scripts explicitly, assume that they're trusted.
}
if (manifest.scripts?.[`pre${scriptName}`]) {
await runLifecycleHooks(`pre${scriptName}`, manifest, lifecycleOpts)
}
await runLifecycleHooks(scriptName, manifest, { ...lifecycleOpts, args: args.slice(1) })
if (manifest.scripts?.[`post${scriptName}`]) {
await runLifecycleHooks(`post${scriptName}`, manifest, lifecycleOpts)
}
return undefined
}
if (!pkg.package.manifest.scripts || !pkg.package.manifest.scripts[scriptName]) {
return
}
hasCommand++
try {
const lifecycleOpts = {
depPath: prefix,
extraBinPaths: opts.extraBinPaths,
pkgRoot: prefix,
rawConfig: opts.rawConfig,
rootNodeModulesDir: await realNodeModulesDir(prefix),
stdio,
unsafePerm: true, // when running scripts explicitly, assume that they're trusted.
}
if (pkg.package.manifest.scripts[`pre${scriptName}`]) {
await runLifecycleHooks(`pre${scriptName}`, pkg.package.manifest, lifecycleOpts)
}
await runLifecycleHooks(scriptName, pkg.package.manifest, { ...lifecycleOpts, args: passedThruArgs })
if (pkg.package.manifest.scripts[`post${scriptName}`]) {
await runLifecycleHooks(`post${scriptName}`, pkg.package.manifest, lifecycleOpts)
}
result.passes++
} catch (err) {
logger.info(err)
if (!opts.bail) {
result.fails.push({
error: err,
message: err.message,
prefix,
})
return
}
const lifecycleOpts = {
depPath: dir,
extraBinPaths: opts.extraBinPaths,
pkgRoot: dir,
rawConfig: opts.rawConfig,
rootNodeModulesDir: await realNodeModulesDir(dir),
stdio: 'inherit',
unsafePerm: true, // when running scripts explicitly, assume that they're trusted.
}
if (manifest.scripts?.[`pre${scriptName}`]) {
await runLifecycleHooks(`pre${scriptName}`, manifest, lifecycleOpts)
}
await runLifecycleHooks(scriptName, manifest, { ...lifecycleOpts, args: args.slice(1) })
if (manifest.scripts?.[`post${scriptName}`]) {
await runLifecycleHooks(`post${scriptName}`, manifest, lifecycleOpts)
}
return undefined
}
}
hasCommand++
try {
const lifecycleOpts = {
depPath: prefix,
extraBinPaths: opts.extraBinPaths,
pkgRoot: prefix,
rawConfig: opts.rawConfig,
rootNodeModulesDir: await realNodeModulesDir(prefix),
stdio,
unsafePerm: true, // when running scripts explicitly, assume that they're trusted.
}
if (pkg.package.manifest.scripts[`pre${scriptName}`]) {
await runLifecycleHooks(`pre${scriptName}`, pkg.package.manifest, lifecycleOpts)
}
await runLifecycleHooks(scriptName, pkg.package.manifest, { ...lifecycleOpts, args: passedThruArgs })
if (pkg.package.manifest.scripts[`post${scriptName}`]) {
await runLifecycleHooks(`post${scriptName}`, pkg.package.manifest, lifecycleOpts)
}
result.passes++
} catch (err) {
logger.info(err)
if (!opts.bail) {
result.fails.push({
error: err,
message: err.message,
prefix,
})
return
}