Comparing version 1.2.1 to 1.2.2
@@ -146,3 +146,3 @@ // | ||
createCSS(styles.css, sheet); | ||
callback(null, sheet, { local: true, remaining: remaining }); | ||
callback(null, null, data, sheet, { local: true, remaining: remaining }); | ||
} else { | ||
@@ -149,0 +149,0 @@ // Use remote copy (re-parse) |
@@ -6,3 +6,3 @@ var path = require('path'), | ||
var less = { | ||
version: [1, 2, 1], | ||
version: [1, 2, 2], | ||
Parser: require('./parser').Parser, | ||
@@ -23,3 +23,3 @@ importer: require('./parser').importer, | ||
parser.parse(input, function (e, root) { | ||
callback(e, root.toCSS(options)); | ||
callback(e, root && root.toCSS && root.toCSS(options)); | ||
}); | ||
@@ -92,5 +92,7 @@ } else { | ||
less.Parser.importer = function (file, paths, callback) { | ||
less.Parser.importer = function (file, paths, callback, env) { | ||
var pathname; | ||
// TODO: Undo this at some point, | ||
// or use different approach. | ||
paths.unshift('.'); | ||
@@ -110,13 +112,17 @@ | ||
fs.readFile(pathname, 'utf-8', function(e, data) { | ||
if (e) sys.error(e); | ||
if (e) return callback(e); | ||
new(less.Parser)({ | ||
paths: [path.dirname(pathname)].concat(paths), | ||
filename: pathname | ||
}).parse(data, function (e, root) { | ||
callback(e, root, data); | ||
}); | ||
new(less.Parser)({ | ||
paths: [path.dirname(pathname)].concat(paths), | ||
filename: pathname | ||
}).parse(data, function (e, root) { | ||
callback(e, root, data); | ||
}); | ||
}); | ||
} else { | ||
callback({ type: 'File', message: "'" + file + "' wasn't found.\n" }); | ||
if (typeof(env.errback) === "function") { | ||
env.errback(file, paths, callback); | ||
} else { | ||
callback({ type: 'File', message: "'" + file + "' wasn't found.\n" }); | ||
} | ||
} | ||
@@ -123,0 +129,0 @@ } |
@@ -194,5 +194,13 @@ var less, tree; | ||
function basename(pathname) { | ||
if (less.mode === 'node') { | ||
return require('path').basename(pathname); | ||
} else { | ||
return pathname.match(/[^\/]+$/)[0]; | ||
} | ||
} | ||
function getInput(e, env) { | ||
if (e.filename && env.filename && (e.filename !== env.filename)) { | ||
return parser.imports.contents[e.filename]; | ||
return parser.imports.contents[basename(e.filename)]; | ||
} else { | ||
@@ -259,3 +267,2 @@ return input; | ||
i = j = current = furthest = 0; | ||
chunks = []; | ||
input = str.replace(/\r\n/g, '\n'); | ||
@@ -266,9 +273,9 @@ | ||
var j = 0, | ||
skip = /[^"'`\{\}\/\(\)]+/g, | ||
skip = /[^"'`\{\}\/\(\)\\]+/g, | ||
comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g, | ||
string = /"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'|`((?:[^`\\\r\n]|\\.)*)`/g, | ||
level = 0, | ||
match, | ||
chunk = chunks[0], | ||
inParam, | ||
inString; | ||
inParam; | ||
@@ -284,5 +291,13 @@ for (var i = 0, c, cc; i < input.length; i++) { | ||
c = input.charAt(i); | ||
comment.lastIndex = i; | ||
comment.lastIndex = string.lastIndex = i; | ||
if (!inString && !inParam && c === '/') { | ||
if (match = string.exec(input)) { | ||
if (match.index === i) { | ||
i += match[0].length; | ||
chunk.push(match[0]); | ||
c = input.charAt(i); | ||
} | ||
} | ||
if (!inParam && c === '/') { | ||
cc = input.charAt(i + 1); | ||
@@ -300,30 +315,17 @@ if (cc === '/' || cc === '*') { | ||
if (c === '{' && !inString && !inParam) { level ++; | ||
chunk.push(c); | ||
} else if (c === '}' && !inString && !inParam) { level --; | ||
chunk.push(c); | ||
chunks[++j] = chunk = []; | ||
} else if (c === '(' && !inString && !inParam) { | ||
chunk.push(c); | ||
inParam = true; | ||
} else if (c === ')' && !inString && inParam) { | ||
chunk.push(c); | ||
inParam = false; | ||
} else { | ||
if (c === '"' || c === "'" || c === '`') { | ||
if (! inString) { | ||
inString = c; | ||
} else { | ||
inString = inString === c ? false : inString; | ||
} | ||
} | ||
chunk.push(c); | ||
switch (c) { | ||
case '{': if (! inParam) { level ++; chunk.push(c); break } | ||
case '}': if (! inParam) { level --; chunk.push(c); chunks[++j] = chunk = []; break } | ||
case '(': if (! inParam) { inParam = true; chunk.push(c); break } | ||
case ')': if ( inParam) { inParam = false; chunk.push(c); break } | ||
default: chunk.push(c); | ||
} | ||
} | ||
if (level > 0) { | ||
throw { | ||
type: 'Syntax', | ||
message: "Missing closing `}`", | ||
error = new(LessError)({ | ||
index: i, | ||
type: 'Parse', | ||
message: "missing closing `}`", | ||
filename: env.filename | ||
}; | ||
}, env); | ||
} | ||
@@ -334,2 +336,6 @@ | ||
if (error) { | ||
return callback(error); | ||
} | ||
// Start with the primary rule. | ||
@@ -1270,3 +1276,3 @@ // The whole syntax tree is held under a Ruleset node, | ||
less.Parser.importer = function (path, paths, callback, env) { | ||
if (path.charAt(0) !== '/' && paths.length > 0) { | ||
if (!/^([a-z]+:)?\//.test(path) && paths.length > 0) { | ||
path = paths[0] + path; | ||
@@ -1277,5 +1283,11 @@ } | ||
// as we need this to evaluate the current stylesheet. | ||
loadStyleSheet({ href: path, title: path, type: env.mime }, callback, true); | ||
loadStyleSheet({ href: path, title: path, type: env.mime }, function (e) { | ||
if (e && typeof(env.errback) === "function") { | ||
env.errback.call(null, path, paths, callback, env); | ||
} else { | ||
callback.apply(null, arguments); | ||
} | ||
}, true); | ||
}; | ||
} | ||
@@ -14,3 +14,3 @@ (function (tree) { | ||
var i = this.index, result | ||
var i = this.index, result; | ||
@@ -17,0 +17,0 @@ var result = (function (op) { |
@@ -165,3 +165,4 @@ (function (tree) { | ||
}).join('').trim(); | ||
}).join(env.compress ? ',' : (paths.length > 3 ? ',\n' : ', ')); | ||
}).join( env.compress ? ',' : ',\n'); | ||
css.push(selector, | ||
@@ -168,0 +169,0 @@ (env.compress ? '{' : ' {\n ') + |
@@ -8,3 +8,3 @@ { | ||
"contributors" : [], | ||
"version" : "1.2.1", | ||
"version" : "1.2.2", | ||
"bin" : { "lessc": "./bin/lessc" }, | ||
@@ -11,0 +11,0 @@ "main" : "./lib/less/index", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2130296
127
45112
14