Skip to content

Commit

Permalink
Fix: use promise API
Browse files Browse the repository at this point in the history
  • Loading branch information
eight04 committed Sep 25, 2018
1 parent 5d07a8c commit a3e7915
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions background/usercss-helper.js
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit a3e7915

Please sign in to comment.