Skip to content

Commit c2dcb74

Browse files
committed
Allow creating parser without options. Fixes less#1373
1 parent 3bb4a10 commit c2dcb74

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

lib/less/env.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@
3030
if (!this.files) { this.files = {}; }
3131

3232
if (!this.currentFileInfo) {
33-
var filename = options.filename || "input";
34-
options.filename = null;
33+
var filename = (options && options.filename) || "input";
3534
var entryPath = filename.replace(/[^\/\\]*$/, "");
35+
if (options) {
36+
options.filename = null;
37+
}
3638
this.currentFileInfo = {
3739
filename: filename,
3840
relativeUrls: this.relativeUrls,
39-
rootpath: options.rootpath || "",
41+
rootpath: (options && options.rootpath) || "",
4042
currentDirectory: entryPath,
4143
entryPath: entryPath,
4244
rootFilename: filename

test/less-test.js

+13
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ runTestSet({strictMath: true, dumpLineNumbers: 'all'}, "debug/", null,
6262
runTestSet({strictMath: true, relativeUrls: false, rootpath: "folder (1)/"}, "static-urls/");
6363
runTestSet({strictMath: true, compress: true}, "compression/");
6464
runTestSet({strictMath: false}, "legacy/");
65+
testNoOptions();
6566

6667
function globalReplacements(input, directory) {
6768
var p = path.join(process.cwd(), directory),
@@ -184,3 +185,15 @@ function toCSS(options, path, callback) {
184185
});
185186
});
186187
}
188+
189+
function testNoOptions() {
190+
totalTests++;
191+
try {
192+
sys.print("- Integration - creating parser without options: ");
193+
new(less.Parser);
194+
} catch(e) {
195+
fail(stylize("FAIL\n", "red"));
196+
return;
197+
}
198+
ok(stylize("OK\n", "green"));
199+
}

0 commit comments

Comments
 (0)