mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Tidy up options
This commit is contained in:
33
bin/lessc
33
bin/lessc
@@ -32,6 +32,15 @@ var continueProcessing = true,
|
||||
// so use this to set the exit code
|
||||
process.on('exit', function() { process.reallyExit(currentErrorcode) });
|
||||
|
||||
var checkArgFunc = function(arg, option) {
|
||||
if (!option) {
|
||||
sys.puts(arg + " option requires a parameter");
|
||||
continueProcessing = false;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
args = args.filter(function (arg) {
|
||||
var match;
|
||||
|
||||
@@ -78,9 +87,11 @@ args = args.filter(function (arg) {
|
||||
options.yuicompress = true;
|
||||
break;
|
||||
case 'max-line-len':
|
||||
options.max_line_len = parseInt(match[2], 10);
|
||||
if (options.max_line_len <= 0) {
|
||||
options.max_line_len = -1;
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.maxLineLen = parseInt(match[2], 10);
|
||||
if (options.maxLineLen <= 0) {
|
||||
options.maxLineLen = -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'no-color':
|
||||
@@ -90,10 +101,7 @@ args = args.filter(function (arg) {
|
||||
options.ieCompat = false;
|
||||
break;
|
||||
case 'include-path':
|
||||
if (!match[2]) {
|
||||
sys.puts("include-path option requires a parameter");
|
||||
continueProcessing = false;
|
||||
} else {
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')
|
||||
.map(function(p) {
|
||||
if (p) {
|
||||
@@ -106,14 +114,13 @@ args = args.filter(function (arg) {
|
||||
case 'O1': options.optimization = 1; break;
|
||||
case 'O2': options.optimization = 2; break;
|
||||
case 'line-numbers':
|
||||
options.dumpLineNumbers = match[2];
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.dumpLineNumbers = match[2];
|
||||
}
|
||||
break;
|
||||
case 'rp':
|
||||
case 'rootpath':
|
||||
if (!match[2]) {
|
||||
sys.puts("rootpath option requires a parameter");
|
||||
continueProcessing = false;
|
||||
} else {
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.rootpath = match[2].replace(/\\/g, '/');
|
||||
}
|
||||
break;
|
||||
@@ -206,7 +213,7 @@ var parseLessFile = function (e, data) {
|
||||
ieCompat: options.ieCompat,
|
||||
compress: options.compress,
|
||||
yuicompress: options.yuicompress,
|
||||
max_line_len: options.max_line_len,
|
||||
maxLineLen: options.maxLineLen,
|
||||
strictMaths: options.strictMaths,
|
||||
strictUnits: options.strictUnits
|
||||
});
|
||||
|
||||
@@ -29,7 +29,7 @@ var lessc_helper = {
|
||||
sys.puts("");
|
||||
sys.puts("options:");
|
||||
sys.puts(" -h, --help Print help (this message) and exit.");
|
||||
sys.puts(" --include-path Set include paths. Separated by `:'. Use `;' on Windows.");
|
||||
sys.puts(" --include-path=PATHS Set include paths. Separated by `:'. Use `;' on Windows.");
|
||||
sys.puts(" -M, --depends Output a makefile import dependency list to stdout");
|
||||
sys.puts(" --no-color Disable colorized output.");
|
||||
sys.puts(" --no-ie-compat Disable IE compatibility checks.");
|
||||
@@ -40,7 +40,7 @@ var lessc_helper = {
|
||||
sys.puts(" -v, --version Print version number and exit.");
|
||||
sys.puts(" -x, --compress Compress output by removing some whitespaces.");
|
||||
sys.puts(" --yui-compress Compress output using ycssmin");
|
||||
sys.puts(" --max-line-len Max line length used by ycssmin");
|
||||
sys.puts(" --max-line-len=LINELEN Max line length used by ycssmin");
|
||||
sys.puts(" -O0, -O1, -O2 Set the parser's optimization level. The lower");
|
||||
sys.puts(" the number, the less nodes it will create in the");
|
||||
sys.puts(" tree. This could matter for debugging, or if you");
|
||||
@@ -51,7 +51,7 @@ var lessc_helper = {
|
||||
sys.puts(" that will output the information within a fake");
|
||||
sys.puts(" media query which is compatible with the SASS");
|
||||
sys.puts(" format, and 'all' which will do both.");
|
||||
sys.puts(" -rp, --rootpath Set rootpath for url rewriting in relative imports and urls.");
|
||||
sys.puts(" -rp, --rootpath=URL Set rootpath for url rewriting in relative imports and urls.");
|
||||
sys.puts(" Works with or withour the relative-urls option.");
|
||||
sys.puts(" -ru, --relative-urls re-write relative urls to the base less file.");
|
||||
sys.puts(" -sm, --strict-maths-off Make maths not require brackets, which is similar behaviour");
|
||||
|
||||
@@ -422,7 +422,7 @@ less.Parser = function Parser(env) {
|
||||
}
|
||||
|
||||
if (options.yuicompress && less.mode === 'node') {
|
||||
return require('ycssmin').cssmin(css, options.max_line_len);
|
||||
return require('ycssmin').cssmin(css, options.maxLineLen);
|
||||
} else if (options.compress) {
|
||||
return css.replace(/(\s)+/g, "$1");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user