Fix @import file loading routine

Again, old fs.open syntax is deprecated, replaced with fs.readFile.
This commit is contained in:
Felix Geisendörfer 2010-10-05 16:59:05 +08:00 committed by Alexis Sellier
parent 8e846a3b11
commit ef71bb0db2

View File

@ -99,24 +99,16 @@ less.Parser.importer = function (file, paths, callback) {
} }
if (pathname) { if (pathname) {
fs.stat(pathname, function (e, stats) { fs.readFile(pathname, 'utf-8', function(e, data) {
if (e) sys.error(e); if (e) sys.error(e);
fs.open(pathname, process.O_RDONLY, stats.mode, function (e, fd) { new(less.Parser)({
if (e) sys.error(e); paths: [path.dirname(pathname)],
filename: pathname
fs.read(fd, stats.size, 0, "utf8", function (e, data) { }).parse(data, function (e, root) {
if (e) sys.error(e); if (e) less.writeError(e);
callback(root);
new(less.Parser)({ });
paths: [path.dirname(pathname)],
filename: pathname
}).parse(data, function (e, root) {
if (e) less.writeError(e);
callback(root);
});
});
});
}); });
} else { } else {
sys.error("file '" + file + "' wasn't found.\n"); sys.error("file '" + file + "' wasn't found.\n");