Merge branch 'master' of github.com:cloudhead/less.js
This commit is contained in:
commit
9b808fd305
48
bin/lessc
48
bin/lessc
@ -62,37 +62,33 @@ if (! input) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
fs.stat(input, function (e, stats) {
|
||||
fs.readFile(input, 'utf-8', function (e, data) {
|
||||
if (e) {
|
||||
sys.puts("lessc: " + e.message);
|
||||
process.exit(1);
|
||||
}
|
||||
fs.open(input, process.O_RDONLY, stats.mode, function (e, fd) {
|
||||
fs.read(fd, stats.size, 0, "utf8", function (e, data) {
|
||||
new(less.Parser)({
|
||||
paths: [path.dirname(input)],
|
||||
optimization: options.optimization,
|
||||
filename: input
|
||||
}).parse(data, function (err, tree) {
|
||||
if (err) {
|
||||
less.writeError(err, options);
|
||||
process.exit(1);
|
||||
|
||||
new(less.Parser)({
|
||||
paths: [path.dirname(input)],
|
||||
optimization: options.optimization,
|
||||
filename: input
|
||||
}).parse(data, function (err, tree) {
|
||||
if (err) {
|
||||
less.writeError(err, options);
|
||||
process.exit(1);
|
||||
} else {
|
||||
try {
|
||||
css = tree.toCSS({ compress: options.compress });
|
||||
if (output) {
|
||||
fd = fs.openSync(output, "w");
|
||||
fs.writeSync(fd, css, 0, "utf8");
|
||||
} else {
|
||||
try {
|
||||
css = tree.toCSS({ compress: options.compress });
|
||||
if (output) {
|
||||
fd = fs.openSync(output, "w");
|
||||
fs.writeSync(fd, css, 0, "utf8");
|
||||
} else {
|
||||
sys.print(css);
|
||||
}
|
||||
} catch (e) {
|
||||
less.writeError(e, options);
|
||||
process.exit(2);
|
||||
}
|
||||
sys.print(css);
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
less.writeError(e, options);
|
||||
process.exit(2);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -6,13 +6,12 @@ var isFileProtocol = (location.protocol === 'file:' ||
|
||||
location.protocol === 'chrome:' ||
|
||||
location.protocol === 'resource:');
|
||||
|
||||
less.env = less.env ||
|
||||
location.hostname == '127.0.0.1' ||
|
||||
location.hostname == '0.0.0.0' ||
|
||||
location.hostname == 'localhost' ||
|
||||
location.port.length > 0 ||
|
||||
isFileProtocol ? 'development'
|
||||
: 'production';
|
||||
less.env = less.env || (location.hostname == '127.0.0.1' ||
|
||||
location.hostname == '0.0.0.0' ||
|
||||
location.hostname == 'localhost' ||
|
||||
location.port.length > 0 ||
|
||||
isFileProtocol ? 'development'
|
||||
: 'production');
|
||||
|
||||
// Load styles asynchronously (default: false)
|
||||
//
|
||||
|
@ -99,24 +99,16 @@ less.Parser.importer = function (file, paths, callback) {
|
||||
}
|
||||
|
||||
if (pathname) {
|
||||
fs.stat(pathname, function (e, stats) {
|
||||
if (e) sys.error(e);
|
||||
fs.readFile(pathname, 'utf-8', function(e, data) {
|
||||
if (e) sys.error(e);
|
||||
|
||||
fs.open(pathname, process.O_RDONLY, stats.mode, function (e, fd) {
|
||||
if (e) sys.error(e);
|
||||
|
||||
fs.read(fd, stats.size, 0, "utf8", function (e, data) {
|
||||
if (e) sys.error(e);
|
||||
|
||||
new(less.Parser)({
|
||||
paths: [path.dirname(pathname)],
|
||||
filename: pathname
|
||||
}).parse(data, function (e, root) {
|
||||
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 {
|
||||
sys.error("file '" + file + "' wasn't found.\n");
|
||||
|
@ -24,7 +24,7 @@ fs.readdirSync('test/less').forEach(function (file) {
|
||||
toCSS('test/less/' + file, function (err, less) {
|
||||
var name = path.basename(file, '.less');
|
||||
|
||||
read(path.join('test/css', name) + '.css', function (e, css) {
|
||||
fs.readFile(path.join('test/css', name) + '.css', 'utf-8', function (e, css) {
|
||||
sys.print("- " + name + ": ")
|
||||
if (less === css) { sys.print(stylize('OK', 'green')) }
|
||||
else if (err) {
|
||||
@ -39,7 +39,7 @@ fs.readdirSync('test/less').forEach(function (file) {
|
||||
|
||||
function toCSS(path, callback) {
|
||||
var tree, css;
|
||||
read(path, function (e, str) {
|
||||
fs.readFile(path, 'utf-8', function (e, str) {
|
||||
if (e) { return callback(e) }
|
||||
|
||||
new(less.Parser)({
|
||||
@ -60,19 +60,6 @@ function toCSS(path, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function read(path, callback) {
|
||||
fs.stat(path, function (e, stats) {
|
||||
if (e) return callback(e);
|
||||
fs.open(path, process.O_RDONLY, stats.mode, function (e, fd) {
|
||||
if (e) return callback(e);
|
||||
fs.read(fd, stats.size, 0, "utf8", function (e, data) {
|
||||
if (e) return callback(e);
|
||||
callback(null, data);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Stylize a string
|
||||
function stylize(str, style) {
|
||||
var styles = {
|
||||
|
Loading…
Reference in New Issue
Block a user