Reject font listing promise on error
This commit is contained in:
parent
650718e0f6
commit
e11c8f9315
1 changed files with 11 additions and 5 deletions
|
@ -17,13 +17,19 @@ module.exports = function(options, allowedFonts) {
|
||||||
var existingFonts = {};
|
var existingFonts = {};
|
||||||
var fontListingPromise = new Promise(function(resolve, reject) {
|
var fontListingPromise = new Promise(function(resolve, reject) {
|
||||||
fs.readdir(options.paths.fonts, function(err, files) {
|
fs.readdir(options.paths.fonts, function(err, files) {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
files.forEach(function(file) {
|
files.forEach(function(file) {
|
||||||
fs.stat(path.join(fontPath, file), function(err, stats) {
|
fs.stat(path.join(fontPath, file), function(err, stats) {
|
||||||
if (!err) {
|
if (err) {
|
||||||
if (stats.isDirectory() &&
|
reject(err);
|
||||||
fs.existsSync(path.join(fontPath, file, '0-255.pbf'))) {
|
return;
|
||||||
existingFonts[path.basename(file)] = true;
|
}
|
||||||
}
|
if (stats.isDirectory() &&
|
||||||
|
fs.existsSync(path.join(fontPath, file, '0-255.pbf'))) {
|
||||||
|
existingFonts[path.basename(file)] = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue