Allow creating parser without options. Fixes #1373

This commit is contained in:
Luke Page
2013-06-19 17:35:39 +01:00
parent 3bb4a10866
commit c2dcb743d3
2 changed files with 18 additions and 3 deletions

View File

@@ -30,13 +30,15 @@
if (!this.files) { this.files = {}; }
if (!this.currentFileInfo) {
var filename = options.filename || "input";
options.filename = null;
var filename = (options && options.filename) || "input";
var entryPath = filename.replace(/[^\/\\]*$/, "");
if (options) {
options.filename = null;
}
this.currentFileInfo = {
filename: filename,
relativeUrls: this.relativeUrls,
rootpath: options.rootpath || "",
rootpath: (options && options.rootpath) || "",
currentDirectory: entryPath,
entryPath: entryPath,
rootFilename: filename

View File

@@ -62,6 +62,7 @@ runTestSet({strictMath: true, dumpLineNumbers: 'all'}, "debug/", null,
runTestSet({strictMath: true, relativeUrls: false, rootpath: "folder (1)/"}, "static-urls/");
runTestSet({strictMath: true, compress: true}, "compression/");
runTestSet({strictMath: false}, "legacy/");
testNoOptions();
function globalReplacements(input, directory) {
var p = path.join(process.cwd(), directory),
@@ -184,3 +185,15 @@ function toCSS(options, path, callback) {
});
});
}
function testNoOptions() {
totalTests++;
try {
sys.print("- Integration - creating parser without options: ");
new(less.Parser);
} catch(e) {
fail(stylize("FAIL\n", "red"));
return;
}
ok(stylize("OK\n", "green"));
}