avancement planning
This commit is contained in:
+67
-58
@@ -2,18 +2,17 @@
|
||||
|
||||
/* eslint indent: [2, 2, {"SwitchCase": 1}] */
|
||||
|
||||
'use strict';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
import { createRequire } from 'module';
|
||||
import fs from '../lib/less-node/fs.js';
|
||||
import * as utils from '../lib/less/utils.js';
|
||||
import * as Constants from '../lib/less/constants.js';
|
||||
import less from '../lib/less-node/index.js';
|
||||
|
||||
var path = require('path');
|
||||
var fs = require('../lib/less-node/fs').default;
|
||||
var os = require('os');
|
||||
var utils = require('../lib/less/utils');
|
||||
var Constants = require('../lib/less/constants');
|
||||
|
||||
var less = require('../lib/less-node').default;
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
var errno;
|
||||
var mkdirp;
|
||||
|
||||
try {
|
||||
errno = require('errno');
|
||||
@@ -65,6 +64,7 @@ var parseVariableOption = function parseVariableOption(option, variables) {
|
||||
};
|
||||
|
||||
var sourceMapFileInline = false;
|
||||
var pendingDeprecations = [];
|
||||
|
||||
function printUsage() {
|
||||
less.lesscHelper.printUsage();
|
||||
@@ -98,53 +98,48 @@ function render() {
|
||||
}
|
||||
|
||||
if (options.sourceMap) {
|
||||
sourceMapOptions.sourceMapInputFilename = input;
|
||||
|
||||
if (!sourceMapOptions.sourceMapFullFilename) {
|
||||
if (!output && !sourceMapFileInline) {
|
||||
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');
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
} // its in the same directory, so always just the basename
|
||||
|
||||
|
||||
if (output) {
|
||||
sourceMapOptions.sourceMapOutputFilename = path.basename(output);
|
||||
sourceMapOptions.sourceMapFullFilename = ''.concat(output, '.map');
|
||||
} // its in the same directory, so always just the basename
|
||||
|
||||
|
||||
if ('sourceMapFullFilename' in sourceMapOptions) {
|
||||
sourceMapOptions.sourceMapFilename = path.basename(sourceMapOptions.sourceMapFullFilename);
|
||||
}
|
||||
} else if (options.sourceMap && !sourceMapFileInline) {
|
||||
var mapFilename = path.resolve(process.cwd(), sourceMapOptions.sourceMapFullFilename);
|
||||
var mapDir = path.dirname(mapFilename);
|
||||
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.sourceMapFilename = path.join(path.relative(outputDir, mapDir), path.basename(sourceMapOptions.sourceMapFullFilename));
|
||||
}
|
||||
|
||||
// Validate conflicting options
|
||||
if (sourceMapOptions.sourceMapURL && sourceMapOptions.disableSourcemapAnnotation) {
|
||||
console.error('You cannot provide flag --source-map-url with --source-map-no-annotation.');
|
||||
console.error('Please remove one of those flags.');
|
||||
process.exitcode = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceMapOptions.sourceMapBasepath === undefined) {
|
||||
sourceMapOptions.sourceMapBasepath = input ? path.dirname(input) : process.cwd();
|
||||
}
|
||||
// Handle explicit sourceMapFullFilename (from --source-map=filename)
|
||||
// Normalization of other options (sourceMapBasepath, sourceMapRootpath, etc.)
|
||||
// is handled automatically in parse-tree.js
|
||||
if (sourceMapOptions.sourceMapFullFilename && !sourceMapFileInline) {
|
||||
var mapFilename = path.resolve(process.cwd(), sourceMapOptions.sourceMapFullFilename);
|
||||
var mapDir = path.dirname(mapFilename);
|
||||
|
||||
if (sourceMapOptions.sourceMapRootpath === undefined) {
|
||||
var pathToMap = path.dirname((sourceMapFileInline ? output : sourceMapOptions.sourceMapFullFilename) || '.');
|
||||
var pathToInput = path.dirname(sourceMapOptions.sourceMapInputFilename || '.');
|
||||
sourceMapOptions.sourceMapRootpath = path.relative(pathToMap, pathToInput);
|
||||
if (output) {
|
||||
var outputDir = path.dirname(output);
|
||||
// Set sourceMapOutputFilename relative to map directory
|
||||
sourceMapOptions.sourceMapOutputFilename = path.join(
|
||||
path.relative(mapDir, outputDir),
|
||||
path.basename(output)
|
||||
);
|
||||
// Set sourceMapFilename relative to output directory (for sourceMappingURL comment)
|
||||
sourceMapOptions.sourceMapFilename = path.join(
|
||||
path.relative(outputDir, mapDir),
|
||||
path.basename(sourceMapOptions.sourceMapFullFilename)
|
||||
);
|
||||
} else {
|
||||
// No output filename, just use basename
|
||||
sourceMapOptions.sourceMapOutputFilename = path.basename(output || 'output.css');
|
||||
sourceMapOptions.sourceMapFilename = path.basename(sourceMapOptions.sourceMapFullFilename);
|
||||
}
|
||||
} else if (!sourceMapOptions.sourceMapFullFilename && output && !sourceMapFileInline) {
|
||||
// No explicit sourcemap filename, derive from output
|
||||
sourceMapOptions.sourceMapOutputFilename = path.basename(output);
|
||||
sourceMapOptions.sourceMapFullFilename = ''.concat(output, '.map');
|
||||
} else if (!output && !sourceMapFileInline) {
|
||||
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');
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!input) {
|
||||
@@ -155,6 +150,7 @@ function render() {
|
||||
return;
|
||||
}
|
||||
|
||||
var mkdirp;
|
||||
var ensureDirectory = function ensureDirectory(filepath) {
|
||||
var dir = path.dirname(filepath);
|
||||
var cmd;
|
||||
@@ -193,7 +189,7 @@ function render() {
|
||||
|
||||
// To fix https://github.com/less/less.js/issues/3646
|
||||
output = output.toString();
|
||||
|
||||
|
||||
fs.writeFile(filename, output, 'utf8', function (err) {
|
||||
if (err) {
|
||||
var description = 'Error: ';
|
||||
@@ -408,11 +404,15 @@ function processPluginQueue() {
|
||||
case 'silent':
|
||||
options.silent = silent = true;
|
||||
break;
|
||||
|
||||
|
||||
case 'quiet':
|
||||
options.quiet = quiet = true;
|
||||
break;
|
||||
|
||||
case 'quiet-deprecations':
|
||||
options.quietDeprecations = true;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
case 'lint':
|
||||
options.lint = true;
|
||||
@@ -458,6 +458,7 @@ function processPluginQueue() {
|
||||
|
||||
case 'js':
|
||||
options.javascriptEnabled = true;
|
||||
pendingDeprecations.push('Warning: Inline JavaScript (--js) is deprecated and will be removed in Less 5.x. Use Less functions or custom plugins instead. (js-eval)');
|
||||
break;
|
||||
|
||||
case 'no-js':
|
||||
@@ -481,6 +482,7 @@ function processPluginQueue() {
|
||||
case 'line-numbers':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.dumpLineNumbers = match[2];
|
||||
pendingDeprecations.push('Warning: The --line-numbers option is deprecated and will be removed in Less 5.x. Use source maps instead (--source-map). (dump-line-numbers)');
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -537,13 +539,13 @@ function processPluginQueue() {
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'ie-compat':
|
||||
console.warn('The --ie-compat option is deprecated, as it has no effect on compilation.');
|
||||
pendingDeprecations.push('Warning: The --ie-compat option is deprecated, as it has no effect on compilation.');
|
||||
break;
|
||||
|
||||
case 'relative-urls':
|
||||
console.warn('The --relative-urls option has been deprecated. Use --rewrite-urls=all.');
|
||||
pendingDeprecations.push('Warning: The --relative-urls option has been deprecated. Use --rewrite-urls=all.');
|
||||
options.rewriteUrls = Constants.RewriteUrls.ALL;
|
||||
break;
|
||||
|
||||
@@ -571,7 +573,7 @@ function processPluginQueue() {
|
||||
|
||||
case 'sm':
|
||||
case 'strict-math':
|
||||
console.warn('The --strict-math option has been deprecated. Use --math=strict.');
|
||||
pendingDeprecations.push('Warning: The --strict-math option has been deprecated. Use --math=strict.');
|
||||
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
if (checkBooleanArg(match[2])) {
|
||||
@@ -586,14 +588,14 @@ function processPluginQueue() {
|
||||
let m = match[2];
|
||||
if (checkArgFunc(arg, m)) {
|
||||
if (m === 'always') {
|
||||
console.warn('--math=always is deprecated and will be removed in the future.');
|
||||
pendingDeprecations.push('Warning: --math=always is deprecated and will be removed in Less 5.x. Use --math=parens-division (default) or --math=parens. (math-always)');
|
||||
options.math = Constants.Math.ALWAYS;
|
||||
} else if (m === 'parens-division') {
|
||||
options.math = Constants.Math.PARENS_DIVISION;
|
||||
} else if (m === 'parens' || m === 'strict') {
|
||||
options.math = Constants.Math.PARENS;
|
||||
} else if (m === 'strict-legacy') {
|
||||
console.warn('--math=strict-legacy has been removed. Defaulting to --math=strict');
|
||||
pendingDeprecations.push('Warning: --math=strict-legacy has been removed. Defaulting to --math=strict.');
|
||||
options.math = Constants.Math.PARENS;
|
||||
}
|
||||
}
|
||||
@@ -650,7 +652,7 @@ function processPluginQueue() {
|
||||
case 'disable-plugin-rule':
|
||||
options.disablePluginRule = true;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
queuePlugins.push({
|
||||
name: arg,
|
||||
@@ -661,9 +663,16 @@ function processPluginQueue() {
|
||||
}
|
||||
});
|
||||
|
||||
// Flush queued deprecation warnings (respects --silent, --quiet, --quiet-deprecations)
|
||||
if (!silent && !quiet && !options.quietDeprecations) {
|
||||
pendingDeprecations.forEach(function (msg) {
|
||||
console.warn(msg);
|
||||
});
|
||||
}
|
||||
|
||||
if (queuePlugins.length > 0) {
|
||||
processPluginQueue();
|
||||
} else {
|
||||
render();
|
||||
}
|
||||
})();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user