| 6 | const BaseCommand = require('../base-cmd.js') |
| 7 | |
| 8 | const 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 |