Skip to content

Commit

Permalink
set less.hasFinished to refresh() promise
Browse files Browse the repository at this point in the history
  • Loading branch information
levithomason committed Oct 14, 2014
1 parent a0b1b2f commit c65bf0f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/less-browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/*global window, document, location */

var less;

/*
TODO - options is now hidden - we should expose it on the less object, but not have it "as" the less object
less = { fileAsync: true }
Expand Down Expand Up @@ -243,8 +242,8 @@ less.modifyVars = function(record) {
};

less.refresh = function (reload, modifyVars) {
return new PromiseConstructor(function(resolve, reject) {
var startTime, endTime;
less.hasFinished = new PromiseConstructor(function (resolve, reject) {
var startTime, endTime, totalMilliseconds;
startTime = endTime = new Date();

loadStyleSheets(function (e, css, _, sheet, webInfo) {
Expand All @@ -262,14 +261,22 @@ less.refresh = function (reload, modifyVars) {
}
less.logger.info("css for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms');
if (webInfo.remaining === 0) {
less.logger.info("less has finished. css generated in " + (new Date() - startTime) + 'ms');
resolve();
totalMilliseconds = new Date() - startTime;
less.logger.info("less has finished. css generated in " + totalMilliseconds + 'ms');
resolve({
startTime: startTime,
endTime: endTime,
totalMilliseconds: totalMilliseconds,
sheets: less.sheets.length
});
}
endTime = new Date();
}, reload, modifyVars);

loadStyles(modifyVars);
});

return less.hasFinished;
};

less.refreshStyles = loadStyles;
Expand Down

0 comments on commit c65bf0f

Please sign in to comment.