Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[api] Make colors.setTheme sync call

  • Loading branch information...
commit 891da6434c3fd7fef0b6a8c78e2e1c410ce6907d 1 parent e33dc81
@Marak authored
Showing with 6 additions and 15 deletions.
  1. +3 −8 colors.js
  2. +3 −7 example.js
View
11 colors.js
@@ -100,19 +100,14 @@ exports.addSequencer('zebra', function (letter, i, exploded) {
return i % 2 === 0 ? letter : letter.inverse;
});
-exports.setTheme = function (theme, cb) {
- if(typeof cb !== 'function') {
- cb = function (err, result) {
- console.log(err);
- };
- }
+exports.setTheme = function (theme) {
if (typeof theme === 'string') {
try {
exports.themes[theme] = require(theme);
applyTheme(exports.themes[theme]);
- cb(null, exports.themes[theme]);
+ return exports.themes[theme];
} catch (err) {
- return cb(err);
+ return err;
}
} else {
applyTheme(theme);
View
10 example.js
@@ -67,11 +67,7 @@ console.log("this is a warning".warn);
console.log("this is an input".input);
// Load a theme from file
-colors.setTheme('./themes/winston-dark.js', function(err){
- if (err) {
- return console.log('error loading theme '.error, err)
- }
- // outputs black text
- console.log("this is an input".input);
-});
+colors.setTheme('./themes/winston-dark.js');
+
+console.log("this is an input".input);
Please sign in to comment.
Something went wrong with that request. Please try again.