get the map file outputting and reference file from the end of the css file

This commit is contained in:
Luke Page
2013-07-19 06:54:02 +01:00
parent 536bfa273c
commit 8c3e304966
5 changed files with 22 additions and 5 deletions

View File

@@ -139,7 +139,9 @@ args = args.filter(function (arg) {
}
break;
case 'source-map':
if (checkArgFunc(arg, match[2])) {
if (!match[2]) {
options.sourceMap = true;
} else {
options.sourceMap = match[2];
}
break;
@@ -186,6 +188,14 @@ if (output) {
}
}
if (options.sourceMap === true) {
if (!output) {
sys.puts("the sourcemap option only has an optional filename if the css filename is given");
return;
}
options.sourceMap = output + ".map";
}
if (! input) {
sys.puts("lessc: no input files");
sys.puts("");
@@ -250,7 +260,8 @@ var parseLessFile = function (e, data) {
ieCompat: options.ieCompat,
compress: options.compress,
cleancss: options.cleancss,
sourceMap: options.sourceMap,
sourceMap: Boolean(options.sourceMap),
sourceMapFilename: options.sourceMap,
writeSourceMap: writeSourceMap,
maxLineLen: options.maxLineLen,
strictMath: options.strictMath,

View File

@@ -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(" --source-map=FILENAME Outputs a sourcemap to the filename.");
sys.puts(" --source-map[=FILENAME] Outputs a v3 sourcemap to the filename (or output filename.map)");
sys.puts(" -rp, --rootpath=URL Set rootpath for url rewriting in relative imports and urls.");
sys.puts(" Works with or without the relative-urls option.");
sys.puts(" -ru, --relative-urls re-write relative urls to the base less file.");

View File

@@ -472,7 +472,8 @@ less.Parser = function Parser(env) {
{
writeSourceMap: options.writeSourceMap,
rootNode: evaldRoot,
contentsMap: parser.imports.contents
contentsMap: parser.imports.contents,
sourceMapFilename: options.sourceMapFilename
});
}

View File

@@ -6,6 +6,7 @@
this._rootNode = options.rootNode;
this._writeSourceMap = options.writeSourceMap;
this._contentsMap = options.contentsMap;
this._sourceMapFilename = options.sourceMapFilename;
this._lineNumber = 0;
this._column = 0;
@@ -50,6 +51,10 @@
this._writeSourceMap(JSON.stringify(this._sourceMapGenerator.toJSON()));
if (this._sourceMapFilename) {
this._css.push("/*# sourceMappingURL=" + this._sourceMapFilename + " */");
}
return this._css.join('');
};

View File

@@ -58,7 +58,7 @@ function getErrorPathReplacementFunction(dir) {
}
function testSourcemap(name, err, compiledLess, doReplacements, sourcemap) {
fs.readFile(path.join('test/sourcemaps', name) + '.json', 'utf8', function (e, expectedSourcemap) {
fs.readFile(path.join('test/', name) + '.json', 'utf8', function (e, expectedSourcemap) {
sys.print("- " + name + ": ");
if (sourcemap === expectedSourcemap) {
ok('OK');