Skip to content

Commit

Permalink
fix(ui): bail access denied folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Jun 10, 2018
1 parent 60de7c4 commit 5984a0d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/@vue/cli-ui/src/graphql-api/connectors/folders.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ const pkgCache = new LRU({

const cwd = require('./cwd')

function isDirectory (file) {
try {
return fs.statSync(file.path).isDirectory()
} catch (e) {
console.warn(e.message)
}
return false
}

async function list (base, context) {
const files = await fs.readdir(base, 'utf8')
return files.map(
Expand All @@ -17,7 +26,7 @@ async function list (base, context) {
name: file
})
).filter(
file => fs.statSync(file.path).isDirectory()
file => isDirectory(file)
)
}

Expand Down Expand Up @@ -46,7 +55,12 @@ function openParent (file, context) {
}

function isPackage (file, context) {
return fs.existsSync(path.join(file, 'package.json'))
try {
return fs.existsSync(path.join(file, 'package.json'))
} catch (e) {
console.warn(e.message)
}
return false
}

function readPackage (file, context, force = false) {
Expand Down

0 comments on commit 5984a0d

Please sign in to comment.