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

Function splitPackageNames

deps/npm/lib/commands/edit.js:8–26  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

6const BaseCommand = require('../base-cmd.js')
7
8const splitPackageNames = (path) => path.split('/')
9// combine scoped parts
10 .reduce((parts, part) => {
11 if (parts.length === 0) {
12 return [part]
13 }
14
15 const lastPart = parts[parts.length - 1]
16 // check if previous part is the first part of a scoped package
17 if (lastPart[0] === '@' && !lastPart.includes('/')) {
18 parts[parts.length - 1] += '/' + part
19 } else {
20 parts.push(part)
21 }
22
23 return parts
24 }, [])
25 .join('/node_modules/')
26 .replace(/(\/node_modules)+/, '/node_modules')
27
28// npm edit <pkg>
29// open the package folder in the $EDITOR

Callers 1

execMethod · 0.85

Calls 5

reduceMethod · 0.80
includesMethod · 0.80
joinMethod · 0.45
splitMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected