Skip to content

Commit

Permalink
fix: fix windows compatibility of fileExistsWithCaseSync
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed Sep 16, 2018
1 parent a570ba0 commit 6b825de
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/@vue/cli-service-global/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ 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)
const { base, dir, root } = path.parse(filepath)

if (dir === '/' || dir === '.') {
if (dir === root || dir === '.') {
return true
}

try {
const filenames = fs.readdirSync(dir)
if (!filenames.includes(path.basename(filepath))) {
if (!filenames.includes(base)) {
return false
}
} catch (e) {
Expand Down

0 comments on commit 6b825de

Please sign in to comment.