mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-20 06:09:56 -06:00
* fix(ui): chrome bug: grid element overflow https://bugs.chromium.org/p/chromium/issues/detail?id=833837 * feat(ui): dependencies view * feat(ui): filter deps
35 lines
830 B
JavaScript
35 lines
830 B
JavaScript
const path = require('path')
|
|
|
|
exports.resolveModuleRoot = function (filePath, id = null) {
|
|
{
|
|
const index = filePath.lastIndexOf(path.sep + 'index.js')
|
|
if (index !== -1) {
|
|
filePath = filePath.substr(0, index)
|
|
}
|
|
}
|
|
if (id) {
|
|
id = id.replace(/\//g, path.sep)
|
|
// With node_modules folder
|
|
let search = `node_modules/${id}`
|
|
let index = filePath.lastIndexOf(search)
|
|
if (index === -1) {
|
|
// Id only
|
|
search = id
|
|
index = filePath.lastIndexOf(search)
|
|
}
|
|
if (index === -1) {
|
|
// Scoped (in dev env)
|
|
index = id.lastIndexOf('/')
|
|
if (index !== -1) {
|
|
search = id.substr(index + 1)
|
|
index = filePath.lastIndexOf(search)
|
|
}
|
|
}
|
|
|
|
if (index !== -1) {
|
|
filePath = filePath.substr(0, index + search.length)
|
|
}
|
|
}
|
|
return filePath
|
|
}
|