lessc (less.js-4.1.2) | : | lessc (less.js-4.1.3) | ||
---|---|---|---|---|
#!/usr/bin/env node | #!/usr/bin/env node | |||
/* eslint indent: [2, 2, {"SwitchCase": 1}] */ | ||||
"use strict"; | "use strict"; | |||
var path = require('path'); | var path = require('path'); | |||
var fs = require('../lib/less-node/fs').default; | var fs = require('../lib/less-node/fs').default; | |||
var os = require('os'); | var os = require('os'); | |||
var utils = require('../lib/less/utils'); | var utils = require('../lib/less/utils'); | |||
var Constants = require('../lib/less/constants'); | var Constants = require('../lib/less/constants'); | |||
var less = require('../lib/less-node').default; | var less = require('../lib/less-node').default; | |||
skipping to change at line 90 | skipping to change at line 93 | |||
input = path.resolve(process.cwd(), input); | input = path.resolve(process.cwd(), input); | |||
} | } | |||
var output = args[2]; | var output = args[2]; | |||
var outputbase = args[2]; | var outputbase = args[2]; | |||
if (output) { | if (output) { | |||
output = path.resolve(process.cwd(), output); | output = path.resolve(process.cwd(), output); | |||
} | } | |||
if (options.disablePluginRule && queuePlugins.length > 0) { | ||||
console.error('--plugin and --disable-plugin-rule may not be used at the sam | ||||
e time'); | ||||
process.exitCode = 1; | ||||
return; | ||||
} | ||||
if (options.sourceMap) { | if (options.sourceMap) { | |||
sourceMapOptions.sourceMapInputFilename = input; | sourceMapOptions.sourceMapInputFilename = input; | |||
if (!sourceMapOptions.sourceMapFullFilename) { | if (!sourceMapOptions.sourceMapFullFilename) { | |||
if (!output && !sourceMapFileInline) { | if (!output && !sourceMapFileInline) { | |||
console.error('the sourcemap option only has an optional filename if the css filename is given'); | console.error('the sourcemap option only has an optional filename if the css filename is given'); | |||
console.error('consider adding --source-map-map-inline which embeds the sourcemap into the css'); | console.error('consider adding --source-map-map-inline which embeds the sourcemap into the css'); | |||
process.exitCode = 1; | process.exitCode = 1; | |||
return; | return; | |||
} // its in the same directory, so always just the basename | } // its in the same directory, so always just the basename | |||
skipping to change at line 114 | skipping to change at line 123 | |||
} // its in the same directory, so always just the basename | } // its in the same directory, so always just the basename | |||
if ('sourceMapFullFilename' in sourceMapOptions) { | if ('sourceMapFullFilename' in sourceMapOptions) { | |||
sourceMapOptions.sourceMapFilename = path.basename(sourceMapOptions.sour ceMapFullFilename); | sourceMapOptions.sourceMapFilename = path.basename(sourceMapOptions.sour ceMapFullFilename); | |||
} | } | |||
} else if (options.sourceMap && !sourceMapFileInline) { | } else if (options.sourceMap && !sourceMapFileInline) { | |||
var mapFilename = path.resolve(process.cwd(), sourceMapOptions.sourceMapFu llFilename); | var mapFilename = path.resolve(process.cwd(), sourceMapOptions.sourceMapFu llFilename); | |||
var mapDir = path.dirname(mapFilename); | var mapDir = path.dirname(mapFilename); | |||
var outputDir = path.dirname(output); // find the path from the map to the output file | var outputDir = path.dirname(output); // find the path from the map to the output file | |||
// eslint-disable-next-line max-len | ||||
sourceMapOptions.sourceMapOutputFilename = path.join(path.relative(mapDir, outputDir), path.basename(output)); // make the sourcemap filename point to the sourcemap relative to the css file output directory | sourceMapOptions.sourceMapOutputFilename = path.join(path.relative(mapDir, outputDir), path.basename(output)); // make the sourcemap filename point to the sourcemap relative to the css file output directory | |||
sourceMapOptions.sourceMapFilename = path.join(path.relative(outputDir, ma pDir), path.basename(sourceMapOptions.sourceMapFullFilename)); | sourceMapOptions.sourceMapFilename = path.join(path.relative(outputDir, ma pDir), path.basename(sourceMapOptions.sourceMapFullFilename)); | |||
} | } | |||
if (sourceMapOptions.sourceMapURL && sourceMapOptions.disableSourcemapAnnota tion) { | if (sourceMapOptions.sourceMapURL && sourceMapOptions.disableSourcemapAnnota tion) { | |||
console.error('You cannot provide flag --source-map-url with --source-map- no-annotation.'); | console.error('You cannot provide flag --source-map-url with --source-map- no-annotation.'); | |||
console.error('Please remove one of those flags.'); | console.error('Please remove one of those flags.'); | |||
process.exitcode = 1; | process.exitcode = 1; | |||
return; | return; | |||
skipping to change at line 181 | skipping to change at line 191 | |||
process.stdout.write("".concat(outputbase, ": ")); | process.stdout.write("".concat(outputbase, ": ")); | |||
} | } | |||
if (!sourceMapFileInline) { | if (!sourceMapFileInline) { | |||
var writeSourceMap = function writeSourceMap() { | var writeSourceMap = function writeSourceMap() { | |||
var output = arguments.length > 0 && arguments[0] !== undefined ? argument s[0] : ''; | var output = arguments.length > 0 && arguments[0] !== undefined ? argument s[0] : ''; | |||
var onDone = arguments.length > 1 ? arguments[1] : undefined; | var onDone = arguments.length > 1 ? arguments[1] : undefined; | |||
var filename = sourceMapOptions.sourceMapFullFilename; | var filename = sourceMapOptions.sourceMapFullFilename; | |||
ensureDirectory(filename); | ensureDirectory(filename); | |||
// To fix https://github.com/less/less.js/issues/3646 | ||||
output = output.toString(); | ||||
fs.writeFile(filename, output, 'utf8', function (err) { | fs.writeFile(filename, output, 'utf8', function (err) { | |||
if (err) { | if (err) { | |||
var description = 'Error: '; | var description = 'Error: '; | |||
if (errno && errno.errno[err.errno]) { | if (errno && errno.errno[err.errno]) { | |||
description += errno.errno[err.errno].description; | description += errno.errno[err.errno].description; | |||
} else { | } else { | |||
description += "".concat(err.code, " ").concat(err.message); | description += "".concat(err.code, " ").concat(err.message); | |||
} | } | |||
skipping to change at line 441 | skipping to change at line 454 | |||
case 'no-color': | case 'no-color': | |||
options.color = false; | options.color = false; | |||
break; | break; | |||
case 'js': | case 'js': | |||
options.javascriptEnabled = true; | options.javascriptEnabled = true; | |||
break; | break; | |||
case 'no-js': | case 'no-js': | |||
console.error('The "--no-js" argument is deprecated, as inline JavaScrip | // eslint-disable-next-line max-len | |||
t ' + 'is disabled by default. Use "--js" to enable inline JavaScript (not recom | console.error('The "--no-js" argument is deprecated, as inline JavaScrip | |||
mended).'); | t is disabled by default. Use "--js" to enable inline JavaScript (not recommende | |||
d).'); | ||||
break; | break; | |||
case 'include-path': | case 'include-path': | |||
if (checkArgFunc(arg, match[2])) { | if (checkArgFunc(arg, match[2])) { | |||
// ; supported on windows. | // ; supported on windows. | |||
// : supported on windows and linux, excluding a drive letter like C:\ so C:\file:D:\file parses to 2 | // : supported on windows and linux, excluding a drive letter like C:\ so C:\file:D:\file parses to 2 | |||
options.paths = match[2].split(os.type().match(/Windows/) ? /:(?!\\)|; / : ':').map(function (p) { | options.paths = match[2].split(os.type().match(/Windows/) ? /:(?!\\)|; / : ':').map(function (p) { | |||
if (p) { | if (p) { | |||
return path.resolve(process.cwd(), p); | return path.resolve(process.cwd(), p); | |||
} | } | |||
skipping to change at line 626 | skipping to change at line 640 | |||
case 'plugin': | case 'plugin': | |||
var splitupArg = match[2].match(/^([^=]+)(=(.*))?/); | var splitupArg = match[2].match(/^([^=]+)(=(.*))?/); | |||
var name = splitupArg[1]; | var name = splitupArg[1]; | |||
var pluginOptions = splitupArg[3]; | var pluginOptions = splitupArg[3]; | |||
queuePlugins.push({ | queuePlugins.push({ | |||
name: name, | name: name, | |||
options: pluginOptions | options: pluginOptions | |||
}); | }); | |||
break; | break; | |||
case 'disable-plugin-rule': | ||||
options.disablePluginRule = true; | ||||
break; | ||||
default: | default: | |||
queuePlugins.push({ | queuePlugins.push({ | |||
name: arg, | name: arg, | |||
options: match[2], | options: match[2], | |||
default: true | default: true | |||
}); | }); | |||
break; | break; | |||
} | } | |||
}); | }); | |||
End of changes. 6 change blocks. | ||||
3 lines changed or deleted | 22 lines changed or added |