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