MCPcopy Index your code
hub / github.com/nodejs/node / execCreate

Method execCreate

deps/npm/lib/commands/init.js:98–153  ·  view source on GitHub ↗
(args, runPath = process.cwd())

Source from the content-addressed store, hash-verified

96 }
97
98 async execCreate (args, runPath = process.cwd()) {
99 const [initerName, ...otherArgs] = args
100 let packageName = initerName
101
102 // Only a scope, possibly with a version
103 if (/^@[^/]+$/.test(initerName)) {
104 const [, scope, version] = initerName.split('@')
105 packageName = `@${scope}/create`
106 if (version) {
107 packageName = `${packageName}@${version}`
108 }
109 } else {
110 const req = npa(initerName)
111 if (req.type === 'git' && req.hosted) {
112 const { user, project } = req.hosted
113 packageName = initerName.replace(`${user}/${project}`, `${user}/create-${project}`)
114 } else if (req.registry) {
115 packageName = `${req.name.replace(/^(@[^/]+\/)?/, '$1create-')}@${req.rawSpec}`
116 } else {
117 throw Object.assign(new Error(
118 'Unrecognized initializer: ' + initerName +
119 '\nFor more package binary executing power check out `npx`:' +
120 '\nhttps://docs.npmjs.com/cli/commands/npx'
121 ), { code: 'EUNSUPPORTED' })
122 }
123 }
124
125 const newArgs = [packageName, ...otherArgs]
126 const {
127 flatOptions,
128 localBin,
129 globalBin,
130 chalk,
131 } = this.npm
132 const scriptShell = this.npm.config.get('script-shell') || undefined
133 const yes = this.npm.config.get('yes')
134
135 // only send the init-private flag if it is set
136 const opts = { ...flatOptions }
137 if (this.npm.config.isDefault('init-private')) {
138 delete opts.initPrivate
139 }
140
141 await libexec({
142 ...opts,
143 args: newArgs,
144 localBin,
145 globalBin,
146 output,
147 chalk,
148 path: this.npm.localPrefix,
149 runPath,
150 scriptShell,
151 yes,
152 })
153 }
154
155 async template (path = process.cwd()) {

Callers 2

execMethod · 0.95
execWorkspacesMethod · 0.95

Calls 4

assignMethod · 0.80
getMethod · 0.65
testMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected