Skip to content

Commit

Permalink
Fix: not match font-face
Browse files Browse the repository at this point in the history
  • Loading branch information
khronosleung committed Mar 18, 2017
1 parent a62a7fa commit b44404b
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,21 @@ function extractsSVG (root, options) {
}
});

if (!item.url) {
return reject('src declaration not found in font-face rule.');
}

// for each font-family declaration
rule.walkDecls('font-family', function (decl) {
item.fontName = trimQuotationMarks(decl.value);
});

if (!item.fontName) {
return reject('font-family not found in font-face rule.');
}
if (item.url) {
// for each font-family declaration
rule.walkDecls('font-family', function (decl) {
item.fontName = trimQuotationMarks(decl.value);
});

if (ABSOLUTE_URL.test(item.url)) {
item.path = path.resolve(options.basePath + item.url);
} else {
item.path = path.resolve(path.dirname(root.source.input.file), item.url);
if (item.fontName) {
if (ABSOLUTE_URL.test(item.url)) {
item.path = path.resolve(options.basePath + item.url);
} else {
item.path = path.resolve(path.dirname(root.source.input.file), item.url);
}
queueMap.push(item);
}
}
queueMap.push(item);
});

resolve([queueMap]);
Expand Down Expand Up @@ -104,7 +100,7 @@ function runGulpIconFont (queueMap) {
if (glyphsResult) {
resolve(glyphsResult);
} else {
reject('file not found');
reject(new Error('file not found'));
}
})
});
Expand Down Expand Up @@ -237,11 +233,8 @@ function updateRule(root, options, results) {
options.hooks.onUpdateRule(root, options, item);
}
});

return Promise.resolve([root, results]);
} else {
return Promise.reject('updateRule results param not array');
}
return Promise.resolve([root, results]);
}

function iconFontPlugin (options) {
Expand Down

0 comments on commit b44404b

Please sign in to comment.