diff --git a/.jscsrc b/.jscsrc
index a69f57ff..a576705f 100644
--- a/.jscsrc
+++ b/.jscsrc
@@ -61,5 +61,13 @@
"===",
"!=",
"!=="
- ]
+ ],
+ "requireSpaceBeforeBlockStatements": true,
+ "requireSpaceBetweenArguments": true,
+ "requireSpacesInConditionalExpression": true,
+ "requireSpacesInForStatement": true,
+ "requireSpacesInNamedFunctionExpression": {
+ "beforeOpeningCurlyBrace": true
+ },
+ "validateIndentation": 4
}
\ No newline at end of file
diff --git a/bin/lessc b/bin/lessc
index 27bdec41..bbb563eb 100755
--- a/bin/lessc
+++ b/bin/lessc
@@ -92,8 +92,11 @@ function printUsage() {
}
match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=(.*))?$/i);
- if (match) { arg = match[1]; }
- else { return arg; }
+ if (match) {
+ arg = match[1];
+ } else {
+ return arg;
+ }
switch (arg) {
case 'v':
@@ -134,7 +137,7 @@ function printUsage() {
if (checkArgFunc(arg, match[2])) {
options.maxLineLen = parseInt(match[2], 10);
if (options.maxLineLen <= 0) {
- options.maxLineLen = -1;
+ options.maxLineLen = -1;
}
}
break;
diff --git a/lib/less-browser/file-manager.js b/lib/less-browser/file-manager.js
index 358f2a56..81cb7e0c 100644
--- a/lib/less-browser/file-manager.js
+++ b/lib/less-browser/file-manager.js
@@ -2,118 +2,118 @@
module.exports = function(options, logger) {
-var AbstractFileManager = require("../less/environment/abstract-file-manager.js");
+ var AbstractFileManager = require("../less/environment/abstract-file-manager.js");
-var fileCache = {};
+ var fileCache = {};
-//TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load
+ //TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load
-function getXMLHttpRequest() {
- if (window.XMLHttpRequest && (window.location.protocol !== "file:" || !("ActiveXObject" in window))) {
- return new XMLHttpRequest();
- } else {
- try {
- /*global ActiveXObject */
- return new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e) {
- logger.error("browser doesn't support AJAX.");
- return null;
- }
- }
-}
-
-var FileManager = function() {
-};
-
-FileManager.prototype = new AbstractFileManager();
-
-FileManager.prototype.alwaysMakePathsAbsolute = function alwaysMakePathsAbsolute() {
- return true;
-};
-FileManager.prototype.join = function join(basePath, laterPath) {
- if (!basePath) {
- return laterPath;
- }
- return this.extractUrlParts(laterPath, basePath).path;
-};
-FileManager.prototype.doXHR = function doXHR(url, type, callback, errback) {
-
- var xhr = getXMLHttpRequest();
- var async = options.isFileProtocol ? options.fileAsync : options.async;
-
- if (typeof xhr.overrideMimeType === 'function') {
- xhr.overrideMimeType('text/css');
- }
- logger.debug("XHR: Getting '" + url + "'");
- xhr.open('GET', url, async);
- xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5');
- xhr.send(null);
-
- function handleResponse(xhr, callback, errback) {
- if (xhr.status >= 200 && xhr.status < 300) {
- callback(xhr.responseText,
- xhr.getResponseHeader("Last-Modified"));
- } else if (typeof errback === 'function') {
- errback(xhr.status, url);
- }
- }
-
- if (options.isFileProtocol && !options.fileAsync) {
- if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) {
- callback(xhr.responseText);
+ function getXMLHttpRequest() {
+ if (window.XMLHttpRequest && (window.location.protocol !== "file:" || !("ActiveXObject" in window))) {
+ return new XMLHttpRequest();
} else {
- errback(xhr.status, url);
- }
- } else if (async) {
- xhr.onreadystatechange = function () {
- if (xhr.readyState == 4) {
- handleResponse(xhr, callback, errback);
+ try {
+ /*global ActiveXObject */
+ return new ActiveXObject("Microsoft.XMLHTTP");
+ } catch (e) {
+ logger.error("browser doesn't support AJAX.");
+ return null;
}
- };
- } else {
- handleResponse(xhr, callback, errback);
- }
-};
-FileManager.prototype.supports = function(filename, currentDirectory, options, environment) {
- return true;
-};
-
-FileManager.prototype.clearFileCache = function() {
- fileCache = {};
-};
-
-FileManager.prototype.loadFile = function loadFile(filename, currentDirectory, options, environment, callback) {
- if (currentDirectory && !this.isPathAbsolute(filename)) {
- filename = currentDirectory + filename;
- }
-
- options = options || {};
-
- // sheet may be set to the stylesheet for the initial load or a collection of properties including
- // some context variables for imports
- var hrefParts = this.extractUrlParts(filename, window.location.href);
- var href = hrefParts.url;
-
- if (options.useFileCache && fileCache[href]) {
- try {
- var lessText = fileCache[href];
- callback(null, { contents: lessText, filename: href, webInfo: { lastModified: new Date() }});
- } catch (e) {
- callback({filename: href, message: "Error loading file " + href + " error was " + e.message});
}
- return;
}
- this.doXHR(href, options.mime, function doXHRCallback(data, lastModified) {
- // per file cache
- fileCache[href] = data;
+ var FileManager = function() {
+ };
- // Use remote copy (re-parse)
- callback(null, { contents: data, filename: href, webInfo: { lastModified: lastModified }});
- }, function doXHRError(status, url) {
- callback({ type: 'File', message: "'" + url + "' wasn't found (" + status + ")", href: href });
- });
-};
+ FileManager.prototype = new AbstractFileManager();
-return FileManager;
+ FileManager.prototype.alwaysMakePathsAbsolute = function alwaysMakePathsAbsolute() {
+ return true;
+ };
+ FileManager.prototype.join = function join(basePath, laterPath) {
+ if (!basePath) {
+ return laterPath;
+ }
+ return this.extractUrlParts(laterPath, basePath).path;
+ };
+ FileManager.prototype.doXHR = function doXHR(url, type, callback, errback) {
+
+ var xhr = getXMLHttpRequest();
+ var async = options.isFileProtocol ? options.fileAsync : options.async;
+
+ if (typeof xhr.overrideMimeType === 'function') {
+ xhr.overrideMimeType('text/css');
+ }
+ logger.debug("XHR: Getting '" + url + "'");
+ xhr.open('GET', url, async);
+ xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5');
+ xhr.send(null);
+
+ function handleResponse(xhr, callback, errback) {
+ if (xhr.status >= 200 && xhr.status < 300) {
+ callback(xhr.responseText,
+ xhr.getResponseHeader("Last-Modified"));
+ } else if (typeof errback === 'function') {
+ errback(xhr.status, url);
+ }
+ }
+
+ if (options.isFileProtocol && !options.fileAsync) {
+ if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) {
+ callback(xhr.responseText);
+ } else {
+ errback(xhr.status, url);
+ }
+ } else if (async) {
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState == 4) {
+ handleResponse(xhr, callback, errback);
+ }
+ };
+ } else {
+ handleResponse(xhr, callback, errback);
+ }
+ };
+ FileManager.prototype.supports = function(filename, currentDirectory, options, environment) {
+ return true;
+ };
+
+ FileManager.prototype.clearFileCache = function() {
+ fileCache = {};
+ };
+
+ FileManager.prototype.loadFile = function loadFile(filename, currentDirectory, options, environment, callback) {
+ if (currentDirectory && !this.isPathAbsolute(filename)) {
+ filename = currentDirectory + filename;
+ }
+
+ options = options || {};
+
+ // sheet may be set to the stylesheet for the initial load or a collection of properties including
+ // some context variables for imports
+ var hrefParts = this.extractUrlParts(filename, window.location.href);
+ var href = hrefParts.url;
+
+ if (options.useFileCache && fileCache[href]) {
+ try {
+ var lessText = fileCache[href];
+ callback(null, { contents: lessText, filename: href, webInfo: { lastModified: new Date() }});
+ } catch (e) {
+ callback({filename: href, message: "Error loading file " + href + " error was " + e.message});
+ }
+ return;
+ }
+
+ this.doXHR(href, options.mime, function doXHRCallback(data, lastModified) {
+ // per file cache
+ fileCache[href] = data;
+
+ // Use remote copy (re-parse)
+ callback(null, { contents: data, filename: href, webInfo: { lastModified: lastModified }});
+ }, function doXHRError(status, url) {
+ callback({ type: 'File', message: "'" + url + "' wasn't found (" + status + ")", href: href });
+ });
+ };
+
+ return FileManager;
};
diff --git a/lib/less-browser/index.js b/lib/less-browser/index.js
index 25ec0a77..ffdfd9db 100644
--- a/lib/less-browser/index.js
+++ b/lib/less-browser/index.js
@@ -6,251 +6,251 @@ var addDataAttr = require("./utils").addDataAttr,
browser = require("./browser");
module.exports = function(window, options) {
-var document = window.document;
-var less = require('../less')();
-module.exports = less;
-less.options = options;
-var environment = less.environment,
- FileManager = require("./file-manager")(options, less.logger),
- fileManager = new FileManager();
-environment.addFileManager(fileManager);
-less.FileManager = FileManager;
+ var document = window.document;
+ var less = require('../less')();
+ //module.exports = less;
+ less.options = options;
+ var environment = less.environment,
+ FileManager = require("./file-manager")(options, less.logger),
+ fileManager = new FileManager();
+ environment.addFileManager(fileManager);
+ less.FileManager = FileManager;
-require("./log-listener")(less, options);
-var errors = require("./error-reporting")(window, less, options);
-var cache = less.cache = options.cache || require("./cache")(window, options, less.logger);
+ require("./log-listener")(less, options);
+ var errors = require("./error-reporting")(window, less, options);
+ var cache = less.cache = options.cache || require("./cache")(window, options, less.logger);
-//Setup user functions
-if (options.functions) {
- less.functions.functionRegistry.addMultiple(options.functions);
-}
-
-var typePattern = /^text\/(x-)?less$/;
-
-function postProcessCSS(styles) {
- if (options.postProcessor && typeof options.postProcessor === 'function') {
- styles = options.postProcessor.call(styles, styles) || styles;
+ //Setup user functions
+ if (options.functions) {
+ less.functions.functionRegistry.addMultiple(options.functions);
}
- return styles;
-}
-function clone(obj) {
- var cloned = {};
- for (var prop in obj) {
- if (obj.hasOwnProperty(prop)) {
- cloned[prop] = obj[prop];
+ var typePattern = /^text\/(x-)?less$/;
+
+ function postProcessCSS(styles) {
+ if (options.postProcessor && typeof options.postProcessor === 'function') {
+ styles = options.postProcessor.call(styles, styles) || styles;
}
+ return styles;
}
- return cloned;
-}
-// only really needed for phantom
-function bind(func, thisArg) {
- var curryArgs = Array.prototype.slice.call(arguments, 2);
- return function() {
- var args = curryArgs.concat(Array.prototype.slice.call(arguments, 0));
- return func.apply(thisArg, args);
- };
-}
+ function clone(obj) {
+ var cloned = {};
+ for (var prop in obj) {
+ if (obj.hasOwnProperty(prop)) {
+ cloned[prop] = obj[prop];
+ }
+ }
+ return cloned;
+ }
-function loadStyles(modifyVars) {
- var styles = document.getElementsByTagName('style'),
- style;
+ // only really needed for phantom
+ function bind(func, thisArg) {
+ var curryArgs = Array.prototype.slice.call(arguments, 2);
+ return function() {
+ var args = curryArgs.concat(Array.prototype.slice.call(arguments, 0));
+ return func.apply(thisArg, args);
+ };
+ }
- for (var i = 0; i < styles.length; i++) {
- style = styles[i];
- if (style.type.match(typePattern)) {
- var instanceOptions = clone(options);
- instanceOptions.modifyVars = modifyVars;
- var lessText = style.innerHTML || '';
- instanceOptions.filename = document.location.href.replace(/#.*$/, '');
+ function loadStyles(modifyVars) {
+ var styles = document.getElementsByTagName('style'),
+ style;
- /*jshint loopfunc:true */
- // use closure to store current style
- less.render(lessText, instanceOptions,
- bind(function(style, e, result) {
- if (e) {
- errors.add(e, "inline");
- } else {
- style.type = 'text/css';
- if (style.styleSheet) {
- style.styleSheet.cssText = result.css;
+ for (var i = 0; i < styles.length; i++) {
+ style = styles[i];
+ if (style.type.match(typePattern)) {
+ var instanceOptions = clone(options);
+ instanceOptions.modifyVars = modifyVars;
+ var lessText = style.innerHTML || '';
+ instanceOptions.filename = document.location.href.replace(/#.*$/, '');
+
+ /*jshint loopfunc:true */
+ // use closure to store current style
+ less.render(lessText, instanceOptions,
+ bind(function(style, e, result) {
+ if (e) {
+ errors.add(e, "inline");
} else {
- style.innerHTML = result.css;
+ style.type = 'text/css';
+ if (style.styleSheet) {
+ style.styleSheet.cssText = result.css;
+ } else {
+ style.innerHTML = result.css;
+ }
}
- }
- }, null, style));
- }
- }
-}
-
-function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {
-
- var instanceOptions = clone(options);
- addDataAttr(instanceOptions, sheet);
- instanceOptions.mime = sheet.type;
-
- if (modifyVars) {
- instanceOptions.modifyVars = modifyVars;
- }
-
- function loadInitialFileCallback(loadedFile) {
-
- var data = loadedFile.contents,
- path = loadedFile.filename,
- webInfo = loadedFile.webInfo;
-
- var newFileInfo = {
- currentDirectory: fileManager.getPath(path),
- filename: path,
- rootFilename: path,
- relativeUrls: instanceOptions.relativeUrls};
-
- newFileInfo.entryPath = newFileInfo.currentDirectory;
- newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory;
-
- if (webInfo) {
- webInfo.remaining = remaining;
-
- if (!instanceOptions.modifyVars) {
- var css = cache.getCSS(path, webInfo);
- if (!reload && css) {
- webInfo.local = true;
- callback(null, css, data, sheet, webInfo, path);
- return;
- }
+ }, null, style));
}
}
+ }
- //TODO add tests around how this behaves when reloading
- errors.remove(path);
+ function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {
+
+ var instanceOptions = clone(options);
+ addDataAttr(instanceOptions, sheet);
+ instanceOptions.mime = sheet.type;
+
+ if (modifyVars) {
+ instanceOptions.modifyVars = modifyVars;
+ }
+
+ function loadInitialFileCallback(loadedFile) {
+
+ var data = loadedFile.contents,
+ path = loadedFile.filename,
+ webInfo = loadedFile.webInfo;
+
+ var newFileInfo = {
+ currentDirectory: fileManager.getPath(path),
+ filename: path,
+ rootFilename: path,
+ relativeUrls: instanceOptions.relativeUrls};
+
+ newFileInfo.entryPath = newFileInfo.currentDirectory;
+ newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory;
+
+ if (webInfo) {
+ webInfo.remaining = remaining;
- instanceOptions.rootFileInfo = newFileInfo;
- less.render(data, instanceOptions, function(e, result) {
- if (e) {
- e.href = path;
- callback(e);
- } else {
- result.css = postProcessCSS(result.css);
if (!instanceOptions.modifyVars) {
- cache.setCSS(sheet.href, webInfo.lastModified, result.css);
+ var css = cache.getCSS(path, webInfo);
+ if (!reload && css) {
+ webInfo.local = true;
+ callback(null, css, data, sheet, webInfo, path);
+ return;
+ }
}
- callback(null, result.css, data, sheet, webInfo, path);
}
+
+ //TODO add tests around how this behaves when reloading
+ errors.remove(path);
+
+ instanceOptions.rootFileInfo = newFileInfo;
+ less.render(data, instanceOptions, function(e, result) {
+ if (e) {
+ e.href = path;
+ callback(e);
+ } else {
+ result.css = postProcessCSS(result.css);
+ if (!instanceOptions.modifyVars) {
+ cache.setCSS(sheet.href, webInfo.lastModified, result.css);
+ }
+ callback(null, result.css, data, sheet, webInfo, path);
+ }
+ });
+ }
+
+ fileManager.loadFile(sheet.href, null, instanceOptions, environment, function(e, loadedFile) {
+ if (e) {
+ callback(e);
+ return;
+ }
+ loadInitialFileCallback(loadedFile);
});
}
- fileManager.loadFile(sheet.href, null, instanceOptions, environment, function(e, loadedFile) {
- if (e) {
- callback(e);
- return;
+ function loadStyleSheets(callback, reload, modifyVars) {
+ for (var i = 0; i < less.sheets.length; i++) {
+ loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1), modifyVars);
}
- loadInitialFileCallback(loadedFile);
- });
-}
-
-function loadStyleSheets(callback, reload, modifyVars) {
- for (var i = 0; i < less.sheets.length; i++) {
- loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1), modifyVars);
}
-}
-function initRunningMode() {
- if (less.env === 'development') {
- less.watchTimer = setInterval(function () {
- if (less.watchMode) {
- fileManager.clearFileCache();
- loadStyleSheets(function (e, css, _, sheet, webInfo) {
- if (e) {
- errors.add(e, e.href || sheet.href);
- } else if (css) {
- browser.createCSS(window.document, css, sheet);
- }
- });
- }
- }, options.poll);
- }
-}
-
-//
-// Watch mode
-//
-less.watch = function () {
- if (!less.watchMode ) {
- less.env = 'development';
- initRunningMode();
- }
- this.watchMode = true;
- return true;
-};
-
-less.unwatch = function () {clearInterval(less.watchTimer); this.watchMode = false; return false; };
-
-//
-// Get all tags with the 'rel' attribute set to "stylesheet/less"
-//
-less.registerStylesheets = function() {
- return new Promise(function(resolve, reject) {
- var links = document.getElementsByTagName('link');
- less.sheets = [];
-
- for (var i = 0; i < links.length; i++) {
- if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
- (links[i].type.match(typePattern)))) {
- less.sheets.push(links[i]);
- }
+ function initRunningMode() {
+ if (less.env === 'development') {
+ less.watchTimer = setInterval(function () {
+ if (less.watchMode) {
+ fileManager.clearFileCache();
+ loadStyleSheets(function (e, css, _, sheet, webInfo) {
+ if (e) {
+ errors.add(e, e.href || sheet.href);
+ } else if (css) {
+ browser.createCSS(window.document, css, sheet);
+ }
+ });
+ }
+ }, options.poll);
}
-
- resolve();
- });
-};
-
-//
-// With this function, it's possible to alter variables and re-render
-// CSS without reloading less-files
-//
-less.modifyVars = function(record) {
- return less.refresh(true, record, false);
-};
-
-less.refresh = function (reload, modifyVars, clearFileCache) {
- if ((reload || clearFileCache) && clearFileCache !== false) {
- fileManager.clearFileCache();
}
- return new Promise(function (resolve, reject) {
- var startTime, endTime, totalMilliseconds;
- startTime = endTime = new Date();
- loadStyleSheets(function (e, css, _, sheet, webInfo) {
- if (e) {
- errors.add(e, e.href || sheet.href);
- reject(e);
- return;
- }
- if (webInfo.local) {
- less.logger.info("loading " + sheet.href + " from cache.");
- } else {
- less.logger.info("rendered " + sheet.href + " successfully.");
- }
- browser.createCSS(window.document, css, sheet);
- less.logger.info("css for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms');
- if (webInfo.remaining === 0) {
- 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);
+ //
+ // Watch mode
+ //
+ less.watch = function () {
+ if (!less.watchMode ) {
+ less.env = 'development';
+ initRunningMode();
+ }
+ this.watchMode = true;
+ return true;
+ };
- loadStyles(modifyVars);
- });
-};
+ less.unwatch = function () {clearInterval(less.watchTimer); this.watchMode = false; return false; };
-less.refreshStyles = loadStyles;
+ //
+ // Get all tags with the 'rel' attribute set to "stylesheet/less"
+ //
+ less.registerStylesheets = function() {
+ return new Promise(function(resolve, reject) {
+ var links = document.getElementsByTagName('link');
+ less.sheets = [];
+
+ for (var i = 0; i < links.length; i++) {
+ if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
+ (links[i].type.match(typePattern)))) {
+ less.sheets.push(links[i]);
+ }
+ }
+
+ resolve();
+ });
+ };
+
+ //
+ // With this function, it's possible to alter variables and re-render
+ // CSS without reloading less-files
+ //
+ less.modifyVars = function(record) {
+ return less.refresh(true, record, false);
+ };
+
+ less.refresh = function (reload, modifyVars, clearFileCache) {
+ if ((reload || clearFileCache) && clearFileCache !== false) {
+ fileManager.clearFileCache();
+ }
+ return new Promise(function (resolve, reject) {
+ var startTime, endTime, totalMilliseconds;
+ startTime = endTime = new Date();
+
+ loadStyleSheets(function (e, css, _, sheet, webInfo) {
+ if (e) {
+ errors.add(e, e.href || sheet.href);
+ reject(e);
+ return;
+ }
+ if (webInfo.local) {
+ less.logger.info("loading " + sheet.href + " from cache.");
+ } else {
+ less.logger.info("rendered " + sheet.href + " successfully.");
+ }
+ browser.createCSS(window.document, css, sheet);
+ less.logger.info("css for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms');
+ if (webInfo.remaining === 0) {
+ 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);
+ });
+ };
+
+ less.refreshStyles = loadStyles;
return less;
};
diff --git a/lib/less-node/file-manager.js b/lib/less-node/file-manager.js
index e32a9e0d..a72711fb 100644
--- a/lib/less-node/file-manager.js
+++ b/lib/less-node/file-manager.js
@@ -84,7 +84,7 @@ FileManager.prototype.loadFileSync = function(filename, currentDirectory, option
try {
fullFilename = filename;
if (paths[i]) {
- fullFilename = path.join(paths[i], fullFilename);
+ fullFilename = path.join(paths[i], fullFilename);
}
filenamesTried.push(fullFilename);
fs.statSync(fullFilename);
@@ -100,7 +100,7 @@ FileManager.prototype.loadFileSync = function(filename, currentDirectory, option
} else {
data = fs.readFileSync(fullFilename, encoding);
result = { contents: data, filename: fullFilename};
- }
+ }
return result;
};
diff --git a/lib/less-rhino/index.js b/lib/less-rhino/index.js
index 97abba1a..3d2aa8bc 100644
--- a/lib/less-rhino/index.js
+++ b/lib/less-rhino/index.js
@@ -39,7 +39,7 @@ function formatError(ctx, options) {
message += stylize(ctx.type + 'Error: ' + ctx.message, 'red');
if (ctx.filename) {
- message += stylize(' in ', 'red') + ctx.filename +
+ message += stylize(' in ', 'red') + ctx.filename +
stylize(' on line ' + ctx.line + ', column ' + (ctx.column + 1) + ':', 'grey');
}
@@ -196,8 +196,12 @@ function writeFile(filename, content) {
}
match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=(.*))?$/i);
- if (match) { arg = match[1]; } // was (?:=([^\s]*)), check!
- else { return arg; }
+ if (match) {
+ arg = match[1];
+ }
+ else {
+ return arg;
+ }
switch (arg) {
case 'v':
@@ -305,10 +309,10 @@ function writeFile(filename, content) {
case 'source-map-output-map-file':
if (checkArgFunc(arg, match[2])) {
options.writeSourceMap = function(sourceMapContent) {
- writeFile(match[2], sourceMapContent);
+ writeFile(match[2], sourceMapContent);
};
}
- break;
+ break;
case 'rp':
case 'rootpath':
if (checkArgFunc(arg, match[2])) {
diff --git a/lib/less/functions/types.js b/lib/less/functions/types.js
index cd55e0cb..9727e33d 100644
--- a/lib/less/functions/types.js
+++ b/lib/less/functions/types.js
@@ -9,7 +9,7 @@ var Keyword = require("../tree/keyword"),
functionRegistry = require("./function-registry");
var isa = function (n, Type) {
- return (n instanceof Type) ? Keyword.True : Keyword.False;
+ return (n instanceof Type) ? Keyword.True : Keyword.False;
},
isunit = function (n, unit) {
if (unit === undefined) {
diff --git a/lib/less/import-manager.js b/lib/less/import-manager.js
index 3fb78cda..22784d77 100644
--- a/lib/less/import-manager.js
+++ b/lib/less/import-manager.js
@@ -41,12 +41,12 @@ module.exports = function(environment) {
var importedEqualsRoot = fullPath === importManager.rootFilename;
if (importOptions.optional && e) {
- callback(null, {rules:[]}, false, null);
+ callback(null, {rules:[]}, false, null);
}
else {
- importManager.files[fullPath] = root;
- if (e && !importManager.error) { importManager.error = e; }
- callback(e, root, importedEqualsRoot, fullPath);
+ importManager.files[fullPath] = root;
+ if (e && !importManager.error) { importManager.error = e; }
+ callback(e, root, importedEqualsRoot, fullPath);
}
};
diff --git a/lib/less/parse-tree.js b/lib/less/parse-tree.js
index 373899b9..de7800c6 100644
--- a/lib/less/parse-tree.js
+++ b/lib/less/parse-tree.js
@@ -3,58 +3,58 @@ var LessError = require('./less-error'),
logger = require("./logger");
module.exports = function(SourceMapBuilder) {
-var ParseTree = function(root, imports) {
- this.root = root;
- this.imports = imports;
-};
+ var ParseTree = function(root, imports) {
+ this.root = root;
+ this.imports = imports;
+ };
-ParseTree.prototype.toCSS = function(options) {
- var evaldRoot, result = {}, sourceMapBuilder;
- try {
- evaldRoot = transformTree(this.root, options);
- } catch (e) {
- throw new LessError(e, this.imports);
- }
-
- try {
- var compress = Boolean(options.compress);
- if (compress) {
- logger.warn("The compress option has been deprecated. We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.");
+ ParseTree.prototype.toCSS = function(options) {
+ var evaldRoot, result = {}, sourceMapBuilder;
+ try {
+ evaldRoot = transformTree(this.root, options);
+ } catch (e) {
+ throw new LessError(e, this.imports);
}
- var toCSSOptions = {
- compress: compress,
- dumpLineNumbers: options.dumpLineNumbers,
- strictUnits: Boolean(options.strictUnits),
- numPrecision: 8};
+ try {
+ var compress = Boolean(options.compress);
+ if (compress) {
+ logger.warn("The compress option has been deprecated. We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.");
+ }
+ var toCSSOptions = {
+ compress: compress,
+ dumpLineNumbers: options.dumpLineNumbers,
+ strictUnits: Boolean(options.strictUnits),
+ numPrecision: 8};
+
+ if (options.sourceMap) {
+ sourceMapBuilder = new SourceMapBuilder(options.sourceMap);
+ result.css = sourceMapBuilder.toCSS(evaldRoot, toCSSOptions, this.imports);
+ } else {
+ result.css = evaldRoot.toCSS(toCSSOptions);
+ }
+ } catch (e) {
+ throw new LessError(e, this.imports);
+ }
+
+ if (options.pluginManager) {
+ var postProcessors = options.pluginManager.getPostProcessors();
+ for (var i = 0; i < postProcessors.length; i++) {
+ result.css = postProcessors[i].process(result.css, { sourceMap: sourceMapBuilder, options: options, imports: this.imports });
+ }
+ }
if (options.sourceMap) {
- sourceMapBuilder = new SourceMapBuilder(options.sourceMap);
- result.css = sourceMapBuilder.toCSS(evaldRoot, toCSSOptions, this.imports);
- } else {
- result.css = evaldRoot.toCSS(toCSSOptions);
+ result.map = sourceMapBuilder.getExternalSourceMap();
}
- } catch (e) {
- throw new LessError(e, this.imports);
- }
- if (options.pluginManager) {
- var postProcessors = options.pluginManager.getPostProcessors();
- for (var i = 0; i < postProcessors.length; i++) {
- result.css = postProcessors[i].process(result.css, { sourceMap: sourceMapBuilder, options: options, imports: this.imports });
+ result.imports = [];
+ for (var file in this.imports.files) {
+ if (this.imports.files.hasOwnProperty(file) && file !== this.imports.rootFilename) {
+ result.imports.push(file);
+ }
}
- }
- if (options.sourceMap) {
- result.map = sourceMapBuilder.getExternalSourceMap();
- }
-
- result.imports = [];
- for (var file in this.imports.files) {
- if (this.imports.files.hasOwnProperty(file) && file !== this.imports.rootFilename) {
- result.imports.push(file);
- }
- }
- return result;
-};
-return ParseTree;
+ return result;
+ };
+ return ParseTree;
};
diff --git a/lib/less/parser/parser.js b/lib/less/parser/parser.js
index 1506bf88..0ead846b 100644
--- a/lib/less/parser/parser.js
+++ b/lib/less/parser/parser.js
@@ -547,8 +547,14 @@ var Parser = function Parser(context, imports, fileInfo) {
elements = null;
while (! (option = parserInput.$re(/^(all)(?=\s*(\)|,))/))) {
e = this.element();
- if (!e) { break; }
- if (elements) { elements.push(e); } else { elements = [ e ]; }
+ if (!e) {
+ break;
+ }
+ if (elements) {
+ elements.push(e);
+ } else {
+ elements = [ e ];
+ }
}
option = option && option[1];
@@ -556,8 +562,11 @@ var Parser = function Parser(context, imports, fileInfo) {
error("Missing target selector for :extend().");
}
extend = new(tree.Extend)(new(tree.Selector)(elements), option, index);
- if (extendList) { extendList.push(extend); } else { extendList = [ extend ]; }
-
+ if (extendList) {
+ extendList.push(extend);
+ } else {
+ extendList = [ extend ];
+ }
} while (parserInput.$char(","));
expect(/^\)/);
@@ -606,7 +615,11 @@ var Parser = function Parser(context, imports, fileInfo) {
break;
}
elem = new(tree.Element)(c, e, elemIndex, fileInfo);
- if (elements) { elements.push(elem); } else { elements = [ elem ]; }
+ if (elements) {
+ elements.push(elem);
+ } else {
+ elements = [ elem ];
+ }
c = parserInput.$char('>');
}
@@ -947,11 +960,19 @@ var Parser = function Parser(context, imports, fileInfo) {
} else if (condition) {
error("CSS guard can only be used at the end of selector");
} else if (extendList) {
- if (allExtends) { allExtends = allExtends.concat(extendList); } else { allExtends = extendList; }
+ if (allExtends) {
+ allExtends = allExtends.concat(extendList);
+ } else {
+ allExtends = extendList;
+ }
} else {
if (allExtends) { error("Extend can only be used at the end of selector"); }
c = parserInput.currentChar();
- if (elements) { elements.push(e); } else { elements = [ e ]; }
+ if (elements) {
+ elements.push(e);
+ } else {
+ elements = [ e ];
+ }
e = null;
}
if (c === '{' || c === '}' || c === ';' || c === ',' || c === ')') {
@@ -1026,7 +1047,11 @@ var Parser = function Parser(context, imports, fileInfo) {
if (!s) {
break;
}
- if (selectors) { selectors.push(s); } else { selectors = [ s ]; }
+ if (selectors) {
+ selectors.push(s);
+ } else {
+ selectors = [ s ];
+ }
parserInput.commentStore.length = 0;
if (s.condition && selectors.length > 1) {
error("Guards are only currently allowed on a single selector.");
@@ -1163,11 +1188,11 @@ var Parser = function Parser(context, imports, fileInfo) {
case "css":
optionName = "less";
value = false;
- break;
+ break;
case "once":
optionName = "multiple";
value = false;
- break;
+ break;
}
options[optionName] = value;
if (! parserInput.$char(',')) { break; }
diff --git a/lib/less/plugin-manager.js b/lib/less/plugin-manager.js
index 97bb65c3..abae2f1c 100644
--- a/lib/less/plugin-manager.js
+++ b/lib/less/plugin-manager.js
@@ -14,7 +14,7 @@ var PluginManager = function(less) {
*/
PluginManager.prototype.addPlugins = function(plugins) {
if (plugins) {
- for (var i = 0;i < plugins.length; i++) {
+ for (var i = 0; i < plugins.length; i++) {
this.addPlugin(plugins[i]);
}
}
diff --git a/lib/less/source-map-output.js b/lib/less/source-map-output.js
index 070b1b87..c1aceaba 100644
--- a/lib/less/source-map-output.js
+++ b/lib/less/source-map-output.js
@@ -34,7 +34,7 @@ module.exports = function (environment) {
if (this._sourceMapBasepath && filename.indexOf(this._sourceMapBasepath) === 0) {
filename = filename.substring(this._sourceMapBasepath.length);
if (filename.charAt(0) === '\\' || filename.charAt(0) === '/') {
- filename = filename.substring(1);
+ filename = filename.substring(1);
}
}
return (this._sourceMapRootpath || "") + filename;
diff --git a/lib/less/tree/anonymous.js b/lib/less/tree/anonymous.js
index bf30c4af..b7d7f2b6 100644
--- a/lib/less/tree/anonymous.js
+++ b/lib/less/tree/anonymous.js
@@ -5,7 +5,7 @@ var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike)
this.index = index;
this.mapLines = mapLines;
this.currentFileInfo = currentFileInfo;
- this.rulesetLike = (typeof rulesetLike === 'undefined')? false : rulesetLike;
+ this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike;
};
Anonymous.prototype = new Node();
Anonymous.prototype.type = "Anonymous";
diff --git a/lib/less/tree/dimension.js b/lib/less/tree/dimension.js
index 4ef1b94e..e9bff7ef 100644
--- a/lib/less/tree/dimension.js
+++ b/lib/less/tree/dimension.js
@@ -71,8 +71,8 @@ Dimension.prototype.operate = function (context, op, other) {
other = other.convertTo(this.unit.usedUnits());
if (context.strictUnits && other.unit.toString() !== unit.toString()) {
- throw new Error("Incompatible units. Change the units or use the unit function. Bad units: '" + unit.toString() +
- "' and '" + other.unit.toString() + "'.");
+ throw new Error("Incompatible units. Change the units or use the unit function. Bad units: '" + unit.toString() +
+ "' and '" + other.unit.toString() + "'.");
}
value = this._operate(context, op, this.value, other.value);
diff --git a/lib/less/tree/extend.js b/lib/less/tree/extend.js
index 71065c73..5ef77baa 100644
--- a/lib/less/tree/extend.js
+++ b/lib/less/tree/extend.js
@@ -11,11 +11,11 @@ var Extend = function Extend(selector, option, index) {
case "all":
this.allowBefore = true;
this.allowAfter = true;
- break;
+ break;
default:
this.allowBefore = false;
this.allowAfter = false;
- break;
+ break;
}
};
Extend.next_id = 0;
diff --git a/lib/less/tree/media.js b/lib/less/tree/media.js
index 8393a640..335e31eb 100644
--- a/lib/less/tree/media.js
+++ b/lib/less/tree/media.js
@@ -138,25 +138,25 @@ Media.prototype.evalNested = function (context) {
return new Ruleset([], []);
};
Media.prototype.permute = function (arr) {
- if (arr.length === 0) {
- return [];
- } else if (arr.length === 1) {
- return arr[0];
- } else {
- var result = [];
- var rest = this.permute(arr.slice(1));
- for (var i = 0; i < rest.length; i++) {
- for (var j = 0; j < arr[0].length; j++) {
- result.push([arr[0][j]].concat(rest[i]));
- }
- }
- return result;
- }
+ if (arr.length === 0) {
+ return [];
+ } else if (arr.length === 1) {
+ return arr[0];
+ } else {
+ var result = [];
+ var rest = this.permute(arr.slice(1));
+ for (var i = 0; i < rest.length; i++) {
+ for (var j = 0; j < arr[0].length; j++) {
+ result.push([arr[0][j]].concat(rest[i]));
+ }
+ }
+ return result;
+ }
};
Media.prototype.bubbleSelectors = function (selectors) {
- if (!selectors) {
- return;
- }
- this.rules = [new Ruleset(selectors.slice(0), [this.rules[0]])];
+ if (!selectors) {
+ return;
+ }
+ this.rules = [new Ruleset(selectors.slice(0), [this.rules[0]])];
};
module.exports = Media;
diff --git a/lib/less/tree/quoted.js b/lib/less/tree/quoted.js
index b5ba8cbd..e1be87d1 100644
--- a/lib/less/tree/quoted.js
+++ b/lib/less/tree/quoted.js
@@ -35,8 +35,8 @@ Quoted.prototype.eval = function (context) {
function iterativeReplace(value, regexp, replacementFnc) {
var evaluatedValue = value;
do {
- value = evaluatedValue;
- evaluatedValue = value.replace(regexp, replacementFnc);
+ value = evaluatedValue;
+ evaluatedValue = value.replace(regexp, replacementFnc);
} while (value !== evaluatedValue);
return evaluatedValue;
}
diff --git a/lib/less/tree/rule.js b/lib/less/tree/rule.js
index a9ebee03..cd2fe0c4 100644
--- a/lib/less/tree/rule.js
+++ b/lib/less/tree/rule.js
@@ -44,7 +44,7 @@ Rule.prototype.eval = function (context) {
// things faster (~10% for benchmark.less):
name = (name.length === 1) && (name[0] instanceof Keyword) ?
name[0].value : evalName(context, name);
- variable = false; // never treat expanded interpolation as new variable name
+ variable = false; // never treat expanded interpolation as new variable name
}
if (name === "font" && !context.strictMath) {
strictMathBypass = true;
diff --git a/lib/less/tree/ruleset.js b/lib/less/tree/ruleset.js
index d2beb905..1cee5814 100644
--- a/lib/less/tree/ruleset.js
+++ b/lib/less/tree/ruleset.js
@@ -255,7 +255,11 @@ Ruleset.prototype.rulesets = function () {
};
Ruleset.prototype.prependRule = function (rule) {
var rules = this.rules;
- if (rules) { rules.unshift(rule); } else { this.rules = [ rule ]; }
+ if (rules) {
+ rules.unshift(rule);
+ } else {
+ this.rules = [ rule ];
+ }
};
Ruleset.prototype.find = function (selector, self, filter) {
self = self || this;
@@ -270,13 +274,13 @@ Ruleset.prototype.find = function (selector, self, filter) {
match = selector.match(rule.selectors[j]);
if (match) {
if (selector.elements.length > match) {
- if (!filter || filter(rule)) {
- foundMixins = rule.find(new Selector(selector.elements.slice(match)), self, filter);
- for (var i = 0; i < foundMixins.length; ++i) {
- foundMixins[i].path.push(rule);
+ if (!filter || filter(rule)) {
+ foundMixins = rule.find(new Selector(selector.elements.slice(match)), self, filter);
+ for (var i = 0; i < foundMixins.length; ++i) {
+ foundMixins[i].path.push(rule);
+ }
+ Array.prototype.push.apply(rules, foundMixins);
}
- Array.prototype.push.apply(rules, foundMixins);
- }
} else {
rules.push({ rule: rule, path: []});
}
@@ -309,19 +313,17 @@ Ruleset.prototype.genCSS = function (context, output) {
sep;
function isRulesetLikeNode(rule, root) {
- // if it has nested rules, then it should be treated like a ruleset
- // medias and comments do not have nested rules, but should be treated like rulesets anyway
- // some directives and anonymous nodes are ruleset like, others are not
- if (typeof rule.isRulesetLike === "boolean")
- {
- return rule.isRulesetLike;
- } else if (typeof rule.isRulesetLike === "function")
- {
- return rule.isRulesetLike(root);
- }
+ // if it has nested rules, then it should be treated like a ruleset
+ // medias and comments do not have nested rules, but should be treated like rulesets anyway
+ // some directives and anonymous nodes are ruleset like, others are not
+ if (typeof rule.isRulesetLike === "boolean") {
+ return rule.isRulesetLike;
+ } else if (typeof rule.isRulesetLike === "function") {
+ return rule.isRulesetLike(root);
+ }
- //anything else is assumed to be a rule
- return false;
+ //anything else is assumed to be a rule
+ return false;
}
for (i = 0; i < this.rules.length; i++) {
diff --git a/lib/less/visitors/to-css-visitor.js b/lib/less/visitors/to-css-visitor.js
index 7bea7ba9..75fc95a7 100644
--- a/lib/less/visitors/to-css-visitor.js
+++ b/lib/less/visitors/to-css-visitor.js
@@ -257,8 +257,8 @@ ToCSSVisitor.prototype = {
var spacedGroups = [];
var lastSpacedGroup = [];
parts.map(function (p) {
- if (p.merge === "+") {
- if (lastSpacedGroup.length > 0) {
+ if (p.merge === "+") {
+ if (lastSpacedGroup.length > 0) {
spacedGroups.push(toExpression(lastSpacedGroup));
}
lastSpacedGroup = [];
diff --git a/test/browser/runner-browser-options.js b/test/browser/runner-browser-options.js
index aaf546b3..64037bbb 100644
--- a/test/browser/runner-browser-options.js
+++ b/test/browser/runner-browser-options.js
@@ -18,34 +18,34 @@ if (window.navigator.userAgent.indexOf("MSIE") >= 0) {
// setup style tags with less and link tags pointing to expected css output
for (var i = 0; i < testFiles.length; i++) {
- var file = testFiles[i],
- lessPath = '/test/less/' + file + '.less',
- cssPath = '/test/css/' + file + '.css',
- lessStyle = document.createElement('style'),
- cssLink = document.createElement('link'),
- lessText = '@import "' + lessPath + '";';
+ var file = testFiles[i],
+ lessPath = '/test/less/' + file + '.less',
+ cssPath = '/test/css/' + file + '.css',
+ lessStyle = document.createElement('style'),
+ cssLink = document.createElement('link'),
+ lessText = '@import "' + lessPath + '";';
- lessStyle.type = 'text/less';
- lessStyle.id = file;
- lessStyle.href = file;
+ lessStyle.type = 'text/less';
+ lessStyle.id = file;
+ lessStyle.href = file;
- if (lessStyle.styleSheet === undefined) {
- lessStyle.appendChild(document.createTextNode(lessText));
- }
+ if (lessStyle.styleSheet === undefined) {
+ lessStyle.appendChild(document.createTextNode(lessText));
+ }
- cssLink.rel = 'stylesheet';
- cssLink.type = 'text/css';
- cssLink.href = cssPath;
- cssLink.id = 'expected-' + file;
+ cssLink.rel = 'stylesheet';
+ cssLink.type = 'text/css';
+ cssLink.href = cssPath;
+ cssLink.id = 'expected-' + file;
- var head = document.getElementsByTagName('head')[0];
+ var head = document.getElementsByTagName('head')[0];
- head.appendChild(lessStyle);
+ head.appendChild(lessStyle);
- if (lessStyle.styleSheet) {
- lessStyle.styleSheet.cssText = lessText;
- }
+ if (lessStyle.styleSheet) {
+ lessStyle.styleSheet.cssText = lessText;
+ }
- head.appendChild(cssLink);
- testSheets[i] = lessStyle;
+ head.appendChild(cssLink);
+ testSheets[i] = lessStyle;
}
diff --git a/test/browser/runner-errors-spec.js b/test/browser/runner-errors-spec.js
index 8f59c597..9d68d04a 100644
--- a/test/browser/runner-errors-spec.js
+++ b/test/browser/runner-errors-spec.js
@@ -1,3 +1,3 @@
describe("less.js error tests", function() {
- testLessErrorsInDocument();
+ testLessErrorsInDocument();
});
diff --git a/test/browser/runner-global-vars-spec.js b/test/browser/runner-global-vars-spec.js
index 6dba8917..075fe017 100644
--- a/test/browser/runner-global-vars-spec.js
+++ b/test/browser/runner-global-vars-spec.js
@@ -1,3 +1,3 @@
describe("less.js global vars", function() {
- testLessEqualsInDocument();
+ testLessEqualsInDocument();
});
diff --git a/test/browser/runner-main-options.js b/test/browser/runner-main-options.js
index f8e0b8b2..87c20af6 100644
--- a/test/browser/runner-main-options.js
+++ b/test/browser/runner-main-options.js
@@ -5,14 +5,14 @@ var less = {
less.strictMath = true;
less.functions = {
add: function(a, b) {
- return new(less.tree.Dimension)(a.value + b.value);
+ return new(less.tree.Dimension)(a.value + b.value);
},
increment: function(a) {
- return new(less.tree.Dimension)(a.value + 1);
+ return new(less.tree.Dimension)(a.value + 1);
},
_color: function(str) {
- if (str.value === "evil red") {
- return new(less.tree.Color)("600");
- }
+ if (str.value === "evil red") {
+ return new(less.tree.Color)("600");
+ }
}
};
\ No newline at end of file
diff --git a/test/browser/runner-main-spec.js b/test/browser/runner-main-spec.js
index 3762b954..05692690 100644
--- a/test/browser/runner-main-spec.js
+++ b/test/browser/runner-main-spec.js
@@ -2,6 +2,6 @@ console.warn("start spec");
describe("less.js main tests", function() {
testLessEqualsInDocument();
it("the global environment", function() {
- expect(window.require).toBe(undefined);
+ expect(window.require).toBe(undefined);
});
});
diff --git a/test/copy-bom.js b/test/copy-bom.js
index 89a04cee..c806381c 100644
--- a/test/copy-bom.js
+++ b/test/copy-bom.js
@@ -11,34 +11,34 @@ module.exports = function() {
var _buff = new Buffer(BUF_LENGTH);
function copyFolderWithBom(src, dest) {
- var stats = fs.lstatSync(src);
- var destFolder = path.dirname(dest);
- var destFolderExists = fs.existsSync(destFolder);
- var performCopy = false;
+ var stats = fs.lstatSync(src);
+ var destFolder = path.dirname(dest);
+ var destFolderExists = fs.existsSync(destFolder);
+ var performCopy = false;
- if (stats.isFile()) {
- if (!destFolderExists) {
- fs.mkdirSync(destFolder);
- }
- if (src.match(/\.(css|less)$/)) {
- copyFileAddingBomSync(src, dest);
- } else {
- copyFileSync(src, dest);
- }
- }
- else if (stats.isDirectory()) {
- if (!fs.existsSync(destFolder)) {
- fs.mkdirSync(destFolder);
- }
- if (!fs.existsSync(dest)) {
- fs.mkdirSync(dest);
- }
- fs.readdirSync(src).forEach(function(d) {
- if (d !== 'bom') {
- copyFolderWithBom(path.join(src, d), path.join(dest, d));
+ if (stats.isFile()) {
+ if (!destFolderExists) {
+ fs.mkdirSync(destFolder);
}
- });
- }
+ if (src.match(/\.(css|less)$/)) {
+ copyFileAddingBomSync(src, dest);
+ } else {
+ copyFileSync(src, dest);
+ }
+ }
+ else if (stats.isDirectory()) {
+ if (!fs.existsSync(destFolder)) {
+ fs.mkdirSync(destFolder);
+ }
+ if (!fs.existsSync(dest)) {
+ fs.mkdirSync(dest);
+ }
+ fs.readdirSync(src).forEach(function(d) {
+ if (d !== 'bom') {
+ copyFolderWithBom(path.join(src, d), path.join(dest, d));
+ }
+ });
+ }
}
function copyFileAddingBomSync(srcFile, destFile) {
@@ -50,20 +50,20 @@ module.exports = function() {
}
function copyFileSync(srcFile, destFile) {
- var fdr = fs.openSync(srcFile, 'r')
- var stat = fs.fstatSync(fdr)
- var fdw = fs.openSync(destFile, 'w', stat.mode)
- var bytesRead = 1
- var pos = 0
+ var fdr = fs.openSync(srcFile, 'r');
+ var stat = fs.fstatSync(fdr);
+ var fdw = fs.openSync(destFile, 'w', stat.mode);
+ var bytesRead = 1;
+ var pos = 0;
while (bytesRead > 0) {
- bytesRead = fs.readSync(fdr, _buff, 0, BUF_LENGTH, pos)
- fs.writeSync(fdw, _buff, 0, bytesRead)
- pos += bytesRead
+ bytesRead = fs.readSync(fdr, _buff, 0, BUF_LENGTH, pos)
+ fs.writeSync(fdw, _buff, 0, bytesRead);
+ pos += bytesRead;
}
- fs.closeSync(fdr)
- fs.closeSync(fdw)
+ fs.closeSync(fdr);
+ fs.closeSync(fdw);
}
return {
diff --git a/test/less-test.js b/test/less-test.js
index c4118205..e1608980 100644
--- a/test/less-test.js
+++ b/test/less-test.js
@@ -2,7 +2,7 @@
module.exports = function() {
var path = require('path'),
- fs = require('fs');
+ fs = require('fs'),
copyBom = require('./copy-bom')();
var less = require('../lib/less-node');
@@ -134,23 +134,23 @@ module.exports = function() {
}
totalTests++;
queue(function() {
- var isSync = true;
- toCSS(options, path.join(normalFolder, filenameNoExtension + ".less"), function (err, result) {
- process.stdout.write("- Test Sync " + filenameNoExtension + ": ");
+ var isSync = true;
+ toCSS(options, path.join(normalFolder, filenameNoExtension + ".less"), function (err, result) {
+ process.stdout.write("- Test Sync " + filenameNoExtension + ": ");
- if (isSync) {
- ok("OK");
- } else {
- fail("Not Sync");
- }
- release();
- });
- isSync = false;
+ if (isSync) {
+ ok("OK");
+ } else {
+ fail("Not Sync");
+ }
+ release();
+ });
+ isSync = false;
});
}
function prepBomTest() {
- copyBom.copyFolderWithBom(normalFolder, bomFolder);
+ copyBom.copyFolderWithBom(normalFolder, bomFolder);
}
function runTestSet(options, foldername, verifyFunction, nameModifier, doReplacements, getFilename) {
@@ -171,7 +171,7 @@ module.exports = function() {
}
function getBasename(file) {
- return foldername + path.basename(file, '.less');
+ return foldername + path.basename(file, '.less');
}
fs.readdirSync(path.join(baseFolder, foldername)).forEach(function (file) {
@@ -228,7 +228,7 @@ module.exports = function() {
fs.readFile(path.join('test/css', css_name) + '.css', 'utf8', function (e, css) {
process.stdout.write("- " + path.join(baseFolder, css_name) + ": ");
- css = css && doReplacements(css, path.join(baseFolder, foldername));
+ css = css && doReplacements(css, path.join(baseFolder, foldername));
if (result.css === css) { ok('OK'); }
else {
difference("FAIL", css, result.css);
@@ -242,12 +242,12 @@ module.exports = function() {
function diff(left, right) {
require('diff').diffLines(left, right).forEach(function(item) {
- if (item.added || item.removed) {
- var text = item.value.replace("\n", String.fromCharCode(182) + "\n").replace('\ufeff', '[[BOM]]');
- process.stdout.write(stylize(text, item.added ? 'green' : 'red'));
- } else {
- process.stdout.write(item.value.replace('\ufeff', '[[BOM]]'));
- }
+ if (item.added || item.removed) {
+ var text = item.value.replace("\n", String.fromCharCode(182) + "\n").replace('\ufeff', '[[BOM]]');
+ process.stdout.write(stylize(text, item.added ? 'green' : 'red'));
+ } else {
+ process.stdout.write(item.value.replace('\ufeff', '[[BOM]]'));
+ }
});
process.stdout.write("\n");
}
@@ -313,7 +313,7 @@ module.exports = function() {
options.paths = options.paths || [];
if (!contains(options.paths, addPath)) {
- options.paths.push(addPath);
+ options.paths.push(addPath);
}
options.filename = require('path').resolve(process.cwd(), path);
options.optimization = options.optimization || 0;
diff --git a/test/modify-vars.js b/test/modify-vars.js
index 802228b2..4f73dce4 100644
--- a/test/modify-vars.js
+++ b/test/modify-vars.js
@@ -1,19 +1,19 @@
var less = require('../lib/less'),
- fs = require('fs')
+ fs = require('fs');
-var input = fs.readFileSync("./test/less/modifyVars/extended.less", 'utf8')
-var expectedCss = fs.readFileSync('./test/css/modifyVars/extended.css', 'utf8')
+var input = fs.readFileSync("./test/less/modifyVars/extended.less", 'utf8');
+var expectedCss = fs.readFileSync('./test/css/modifyVars/extended.css', 'utf8');
var options = {
- modifyVars: JSON.parse(fs.readFileSync("./test/less/modifyVars/extended.json", 'utf8'))
-}
+ modifyVars: JSON.parse(fs.readFileSync("./test/less/modifyVars/extended.json", 'utf8'))
+};
less.render(input, options, function (err, result) {
- if (err) {
- console.log(err);
- }
- if (result.css === expectedCss) {
- console.log("PASS");
- } else {
- console.log("FAIL");
- }
+ if (err) {
+ console.log(err);
+ }
+ if (result.css === expectedCss) {
+ console.log("PASS");
+ } else {
+ console.log("FAIL");
+ }
});