mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-25 08:38:57 -06:00
fix: findExisting should be case sensitive
closes #2305 We have added `case-sensitive-paths-webpack-plugin` to the base config. So the filename of instant prototyping entry should also be case-sensitive.
This commit is contained in:
@@ -3,9 +3,31 @@ const path = require('path')
|
||||
|
||||
exports.toPlugin = id => ({ id, apply: require(id) })
|
||||
|
||||
// Based on https://stackoverflow.com/questions/27367261/check-if-file-exists-case-sensitive
|
||||
// Case checking is required, to avoid errors raised by case-sensitive-paths-webpack-plugin
|
||||
function fileExistsWithCaseSync (filepath) {
|
||||
const dir = path.dirname(filepath)
|
||||
|
||||
if (dir === '/' || dir === '.') {
|
||||
return true
|
||||
}
|
||||
|
||||
try {
|
||||
const filenames = fs.readdirSync(dir)
|
||||
if (!filenames.includes(path.basename(filepath))) {
|
||||
return false
|
||||
}
|
||||
} catch (e) {
|
||||
// dir does not exist
|
||||
return false
|
||||
}
|
||||
|
||||
return fileExistsWithCaseSync(dir)
|
||||
}
|
||||
|
||||
exports.findExisting = (context, files) => {
|
||||
for (const file of files) {
|
||||
if (fs.existsSync(path.join(context, file))) {
|
||||
if (fileExistsWithCaseSync(path.join(context, file))) {
|
||||
return file
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user