A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/cli/commit/ad7ab8c19994c1d2a452278edba65968185d3871 below:

lazy loading optimizations (#7388) · npm/cli@ad7ab8c · GitHub

1 -

const runScript = require('@npmcli/run-script')

2 -

const { isServerPackage } = runScript

3 -

const pkgJson = require('@npmcli/package-json')

4 1

const { log, output } = require('proc-log')

5 -

const didYouMean = require('../utils/did-you-mean.js')

6 -

const { isWindowsShell } = require('../utils/is-windows.js')

7 - 8 -

const cmdList = [

9 -

'publish',

10 -

'install',

11 -

'uninstall',

12 -

'test',

13 -

'stop',

14 -

'start',

15 -

'restart',

16 -

'version',

17 -

].reduce((l, p) => l.concat(['pre' + p, p, 'post' + p]), [])

2 +

const pkgJson = require('@npmcli/package-json')

18 3 19 4

const BaseCommand = require('../base-command.js')

20 5

class RunScript extends BaseCommand {

@@ -64,9 +49,7 @@ class RunScript extends BaseCommand {

64 49

}

65 50 66 51

async run ([event, ...args], { path = this.npm.localPrefix, pkg } = {}) {

67 -

// this || undefined is because runScript will be unhappy with the default

68 -

// null value

69 -

const scriptShell = this.npm.config.get('script-shell') || undefined

52 +

const runScript = require('@npmcli/run-script')

70 53 71 54

if (!pkg) {

72 55

const { content } = await pkgJson.normalize(path)

@@ -77,19 +60,21 @@ class RunScript extends BaseCommand {

77 60

if (event === 'restart' && !scripts.restart) {

78 61

scripts.restart = 'npm stop --if-present && npm start'

79 62

} else if (event === 'env' && !scripts.env) {

63 +

const { isWindowsShell } = require('../utils/is-windows.js')

80 64

scripts.env = isWindowsShell ? 'SET' : 'env'

81 65

}

82 66 83 67

pkg.scripts = scripts

84 68 85 69

if (

86 70

!Object.prototype.hasOwnProperty.call(scripts, event) &&

87 -

!(event === 'start' && (await isServerPackage(path)))

71 +

!(event === 'start' && (await runScript.isServerPackage(path)))

88 72

) {

89 73

if (this.npm.config.get('if-present')) {

90 74

return

91 75

}

92 76 77 +

const didYouMean = require('../utils/did-you-mean.js')

93 78

const suggestions = await didYouMean(path, event)

94 79

throw new Error(

95 80

`Missing script: "${event}"${suggestions}\n\nTo see a list of scripts, run:\n npm run`

@@ -111,7 +96,9 @@ class RunScript extends BaseCommand {

111 96

for (const [ev, evArgs] of events) {

112 97

await runScript({

113 98

path,

114 -

scriptShell,

99 +

// this || undefined is because runScript will be unhappy with the

100 +

// default null value

101 +

scriptShell: this.npm.config.get('script-shell') || undefined,

115 102

stdio: 'inherit',

116 103

pkg,

117 104

event: ev,

@@ -147,6 +134,17 @@ class RunScript extends BaseCommand {

147 134

return allScripts

148 135

}

149 136 137 +

// TODO this is missing things like prepare, prepublishOnly, and dependencies

138 +

const cmdList = [

139 +

'preinstall', 'install', 'postinstall',

140 +

'prepublish', 'publish', 'postpublish',

141 +

'prerestart', 'restart', 'postrestart',

142 +

'prestart', 'start', 'poststart',

143 +

'prestop', 'stop', 'poststop',

144 +

'pretest', 'test', 'posttest',

145 +

'preuninstall', 'uninstall', 'postuninstall',

146 +

'preversion', 'version', 'postversion',

147 +

]

150 148

const indent = '\n '

151 149

const prefix = ' '

152 150

const cmds = []


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4