Fix #117 ENOENT when infering flash

This commit is contained in:
Jia Hao 2016-02-26 03:13:11 +08:00
parent 866991d6a1
commit 0ed5bd8c7b
1 changed files with 11 additions and 1 deletions

View File

@ -29,8 +29,18 @@ function inferFlash() {
*/
function findSync(pattern, base, findDir) {
const matches = [];
(function findSyncRecurse(base) {
const children = fs.readdirSync(base);
let children;
try {
children = fs.readdirSync(base);
} catch (exception) {
if (exception.code === 'ENOENT') {
return;
}
throw exception;
}
children.forEach(child => {
const childPath = path.join(base, child);
const childIsDirectory = fs.lstatSync(childPath).isDirectory();