Fix: use promise API

This commit is contained in:
eight 2018-09-25 21:11:54 +08:00
parent 5d07a8cd4e
commit a3e7915199

View File

@ -40,14 +40,13 @@
if (style.usercssData) { if (style.usercssData) {
return Promise.resolve(style); return Promise.resolve(style);
} }
try {
const {sourceCode} = style;
// allow sourceCode to be normalized // allow sourceCode to be normalized
const {sourceCode} = style;
delete style.sourceCode; delete style.sourceCode;
return Promise.resolve(Object.assign(usercss.buildMeta(sourceCode), style));
} catch (e) { return usercss.buildMeta(sourceCode)
return Promise.reject(e); .then(newStyle => Object.assign(newStyle, style));
}
} }
function assignVars(style) { function assignVars(style) {
@ -59,7 +58,8 @@
style.id = dup.id; style.id = dup.id;
if (style.reason !== 'config') { if (style.reason !== 'config') {
// preserve style.vars during update // preserve style.vars during update
usercss.assignVars(style, dup); return usercss.assignVars(style, dup)
.then(() => style);
} }
} }
return style; return style;