Skip to content

Commit 3fc8944

Browse files
committed
Tidy up options
1 parent fc56975 commit 3fc8944

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

bin/lessc

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ var continueProcessing = true,
3232
// so use this to set the exit code
3333
process.on('exit', function() { process.reallyExit(currentErrorcode) });
3434

35+
var checkArgFunc = function(arg, option) {
36+
if (!option) {
37+
sys.puts(arg + " option requires a parameter");
38+
continueProcessing = false;
39+
return false;
40+
}
41+
return true;
42+
}
43+
3544
args = args.filter(function (arg) {
3645
var match;
3746

@@ -78,9 +87,11 @@ args = args.filter(function (arg) {
7887
options.yuicompress = true;
7988
break;
8089
case 'max-line-len':
81-
options.max_line_len = parseInt(match[2], 10);
82-
if (options.max_line_len <= 0) {
83-
options.max_line_len = -1;
90+
if (checkArgFunc(arg, match[2])) {
91+
options.maxLineLen = parseInt(match[2], 10);
92+
if (options.maxLineLen <= 0) {
93+
options.maxLineLen = -1;
94+
}
8495
}
8596
break;
8697
case 'no-color':
@@ -90,10 +101,7 @@ args = args.filter(function (arg) {
90101
options.ieCompat = false;
91102
break;
92103
case 'include-path':
93-
if (!match[2]) {
94-
sys.puts("include-path option requires a parameter");
95-
continueProcessing = false;
96-
} else {
104+
if (checkArgFunc(arg, match[2])) {
97105
options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')
98106
.map(function(p) {
99107
if (p) {
@@ -106,14 +114,13 @@ args = args.filter(function (arg) {
106114
case 'O1': options.optimization = 1; break;
107115
case 'O2': options.optimization = 2; break;
108116
case 'line-numbers':
109-
options.dumpLineNumbers = match[2];
117+
if (checkArgFunc(arg, match[2])) {
118+
options.dumpLineNumbers = match[2];
119+
}
110120
break;
111121
case 'rp':
112122
case 'rootpath':
113-
if (!match[2]) {
114-
sys.puts("rootpath option requires a parameter");
115-
continueProcessing = false;
116-
} else {
123+
if (checkArgFunc(arg, match[2])) {
117124
options.rootpath = match[2].replace(/\\/g, '/');
118125
}
119126
break;
@@ -206,7 +213,7 @@ var parseLessFile = function (e, data) {
206213
ieCompat: options.ieCompat,
207214
compress: options.compress,
208215
yuicompress: options.yuicompress,
209-
max_line_len: options.max_line_len,
216+
maxLineLen: options.maxLineLen,
210217
strictMaths: options.strictMaths,
211218
strictUnits: options.strictUnits
212219
});

lib/less/lessc_helper.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var lessc_helper = {
2929
sys.puts("");
3030
sys.puts("options:");
3131
sys.puts(" -h, --help Print help (this message) and exit.");
32-
sys.puts(" --include-path Set include paths. Separated by `:'. Use `;' on Windows.");
32+
sys.puts(" --include-path=PATHS Set include paths. Separated by `:'. Use `;' on Windows.");
3333
sys.puts(" -M, --depends Output a makefile import dependency list to stdout");
3434
sys.puts(" --no-color Disable colorized output.");
3535
sys.puts(" --no-ie-compat Disable IE compatibility checks.");
@@ -40,7 +40,7 @@ var lessc_helper = {
4040
sys.puts(" -v, --version Print version number and exit.");
4141
sys.puts(" -x, --compress Compress output by removing some whitespaces.");
4242
sys.puts(" --yui-compress Compress output using ycssmin");
43-
sys.puts(" --max-line-len Max line length used by ycssmin");
43+
sys.puts(" --max-line-len=LINELEN Max line length used by ycssmin");
4444
sys.puts(" -O0, -O1, -O2 Set the parser's optimization level. The lower");
4545
sys.puts(" the number, the less nodes it will create in the");
4646
sys.puts(" tree. This could matter for debugging, or if you");
@@ -51,7 +51,7 @@ var lessc_helper = {
5151
sys.puts(" that will output the information within a fake");
5252
sys.puts(" media query which is compatible with the SASS");
5353
sys.puts(" format, and 'all' which will do both.");
54-
sys.puts(" -rp, --rootpath Set rootpath for url rewriting in relative imports and urls.");
54+
sys.puts(" -rp, --rootpath=URL Set rootpath for url rewriting in relative imports and urls.");
5555
sys.puts(" Works with or withour the relative-urls option.");
5656
sys.puts(" -ru, --relative-urls re-write relative urls to the base less file.");
5757
sys.puts(" -sm, --strict-maths-off Make maths not require brackets, which is similar behaviour");

lib/less/parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ less.Parser = function Parser(env) {
422422
}
423423

424424
if (options.yuicompress && less.mode === 'node') {
425-
return require('ycssmin').cssmin(css, options.max_line_len);
425+
return require('ycssmin').cssmin(css, options.maxLineLen);
426426
} else if (options.compress) {
427427
return css.replace(/(\s)+/g, "$1");
428428
} else {

0 commit comments

Comments
 (0)