[Pkg-javascript-commits] [less.js] 27/50: make some changes suggested in #1107 to improve open file handles
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:22:37 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v1.7.1
in repository less.js.
commit 028fe1a4ca50dbce920e9b1b04cce87459c8dac0
Author: Luke Page <luke.a.page at gmail.com>
Date: Tue May 6 06:50:40 2014 +0100
make some changes suggested in #1107 to improve open file handles
---
lib/less/index.js | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/lib/less/index.js b/lib/less/index.js
index 1421788..715ea5a 100644
--- a/lib/less/index.js
+++ b/lib/less/index.js
@@ -24,7 +24,7 @@ var less = {
var css;
try {
css = root && root.toCSS && root.toCSS(options);
- }
+ }
catch (err) { callback(err); return; }
callback(null, css);
});
@@ -34,7 +34,7 @@ var less = {
process.nextTick(function () {
parser.parse(input, function (e, root) {
if (e) { return ee.emit('error', e); }
- try { ee.emit('success', root.toCSS(options)); }
+ try { ee.emit('success', root.toCSS(options)); }
catch (err) { ee.emit('error', err); }
});
});
@@ -143,13 +143,13 @@ less.Parser.fileLoader = function (file, currentFileInfo, callback, env) {
function handleDataAndCallCallback(data) {
var j = file.lastIndexOf('/');
- // Pass on an updated rootpath if path of imported file is relative and file
+ // Pass on an updated rootpath if path of imported file is relative and file
// is in a (sub|sup) directory
- //
- // Examples:
+ //
+ // Examples:
// - If path of imported file is 'module/nav/nav.less' and rootpath is 'less/',
// then rootpath should become 'less/module/nav/'
- // - If path of imported file is '../mixins.less' and rootpath is 'less/',
+ // - If path of imported file is '../mixins.less' and rootpath is 'less/',
// then rootpath should become 'less/../'
if(newFileInfo.relativeUrls && !/^(?:[a-z-]+:|\/)/.test(file) && j != -1) {
var relativeSubDirectory = file.slice(0, j+1);
@@ -160,7 +160,7 @@ less.Parser.fileLoader = function (file, currentFileInfo, callback, env) {
callback(null, data, pathname, newFileInfo);
}
-
+
var isUrl = isUrlRe.test( file );
if (isUrl || isUrlRe.test(currentFileInfo.currentDirectory)) {
if (request === undefined) {
@@ -227,8 +227,13 @@ less.Parser.fileLoader = function (file, currentFileInfo, callback, env) {
tryPathIndex(i + 1);
} else {
fs.readFile(pathname, 'utf-8', function(e, data) {
- if (e) { callback(e); }
- handleDataAndCallCallback(data);
+ if (e) { callback(e); return; }
+
+ // do processing in the next tick to allow
+ // file handling to dispose
+ process.nextTick(function() {
+ handleDataAndCallCallback(data);
+ });
});
}
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git
More information about the Pkg-javascript-commits
mailing list