less 2.7.1 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.travis.yml CHANGED
@@ -1,19 +1,15 @@
1
1
  language: node_js
2
2
  node_js:
3
- - "4.2.0"
4
- - "4.0.0"
3
+ - "6"
4
+ - "4"
5
5
  - "0.12"
6
6
  - "0.10"
7
- before_install:
8
- - mkdir travis-phantomjs
9
- - wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
10
- - tar -xvf $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis-phantomjs
11
- - export PATH=$PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH
12
7
  install:
13
8
  - npm install -g grunt-cli
14
9
  - npm install
15
10
  env:
16
11
  global:
12
+ - PHANTOMJS_CDNURL=http://cnpmjs.org/downloads
17
13
  - secure: TrNVruWYaUK5ALga1y7wRY+MLjWJECUSCsBmKW5EUmIevOUxqHWu7M89FANKxstEeFRRAGH3QJbloRxnzIgh0U0ah5npE9XA1bYXGO5khoXeIyk7pNRfjIo8aEnJH1Vp8vWA6J6ovxdJ7lCFKEGvGKxGde50knVl7KFVVULlX2U=
18
14
  - secure: Rzh+CEI7YRvvVkOruPE8Z0dkU0s13V6b6cpqbN72vxbJl/Jm5PUZkjTFJdkWJrW3ErhCKX6EC7XdGvrclqEA9WAqKzrecqCJYqTnw4MwqiAj6F9wqE/BqhoWg4xPxm0MK/7eJMvLCgjNpe+gc1CaeFJZkLSNWn6nOFke+vVlf9Q=
19
15
  sudo: false
package/appveyor.yml CHANGED
@@ -4,6 +4,7 @@ environment:
4
4
  - nodejs_version: "0.10"
5
5
  - nodejs_version: "0.12"
6
6
  - nodejs_version: "4"
7
+ - nodejs_version: "6"
7
8
 
8
9
  # Install scripts. (runs after repo cloning)
9
10
  install:
package/bin/lessc CHANGED
@@ -40,18 +40,32 @@ var silent = false,
40
40
  plugins: plugins
41
41
  };
42
42
  var sourceMapOptions = {};
43
- var continueProcessing = true,
44
- currentErrorcode;
45
-
46
- // calling process.exit does not flush stdout always
47
- // so use this to set the exit code
48
- process.on('exit', function() { process.reallyExit(currentErrorcode); });
43
+ var continueProcessing = true;
44
+
45
+ // Calling process.exit does not flush stdout always. Instead of exiting the process, we set the process' exitCode,
46
+ // close all handles and wait for the event loop to exit the process.
47
+ // @see https://github.com/nodejs/node/issues/6409
48
+ // Unfortunately, node 0.10.x does not support setting process.exitCode, so we need to call reallyExit() explicitly.
49
+ // @see https://nodejs.org/api/process.html#process_process_exitcode
50
+ // Additionally we also need to make sure that uncaughtExceptions are never swallowed.
51
+ // @see https://github.com/less/less.js/issues/2881
52
+ // This code can safely be removed if node 0.10.x is not supported anymore.
53
+ process.on("exit", function() { process.reallyExit(process.exitCode); });
54
+ process.on("uncaughtException", function(err) {
55
+ console.error(err);
56
+ process.exitCode = 1;
57
+ });
58
+ // This code will still be required because otherwise rejected promises would not be reported to the user
59
+ process.on("unhandledRejection", function(err) {
60
+ console.error(err);
61
+ process.exitCode = 1;
62
+ });
49
63
 
50
64
  var checkArgFunc = function(arg, option) {
51
65
  if (!option) {
52
66
  console.error(arg + " option requires a parameter");
53
67
  continueProcessing = false;
54
- currentErrorcode = 1;
68
+ process.exitCode = 1;
55
69
  return false;
56
70
  }
57
71
  return true;
@@ -62,7 +76,7 @@ var checkBooleanArg = function(arg) {
62
76
  if (!onOff) {
63
77
  console.error(" unable to parse " + arg + " as a boolean. use one of on/t/true/y/yes/off/f/false/n/no");
64
78
  continueProcessing = false;
65
- currentErrorcode = 1;
79
+ process.exitCode = 1;
66
80
  return false;
67
81
  }
68
82
  return Boolean(onOff[2]);
@@ -252,7 +266,7 @@ function printUsage() {
252
266
  } else {
253
267
  console.error("Unable to load plugin " + name +
254
268
  " please make sure that it is installed under or at the same level as less");
255
- currentErrorcode = 1;
269
+ process.exitCode = 1;
256
270
  }
257
271
  break;
258
272
  default:
@@ -263,7 +277,7 @@ function printUsage() {
263
277
  console.error("Unable to interpret argument " + arg +
264
278
  " - if it is a plugin (less-plugin-" + arg + "), make sure that it is installed under or at" +
265
279
  " the same level as less");
266
- currentErrorcode = 1;
280
+ process.exitCode = 1;
267
281
  }
268
282
  break;
269
283
  }
@@ -288,15 +302,20 @@ function printUsage() {
288
302
  sourceMapOptions.sourceMapInputFilename = input;
289
303
  if (!sourceMapOptions.sourceMapFullFilename) {
290
304
  if (!output && !sourceMapFileInline) {
291
- console.log("the sourcemap option only has an optional filename if the css filename is given");
292
- console.log("consider adding --source-map-map-inline which embeds the sourcemap into the css");
305
+ console.error("the sourcemap option only has an optional filename if the css filename is given");
306
+ console.error("consider adding --source-map-map-inline which embeds the sourcemap into the css");
307
+ process.exitCode = 1;
293
308
  return;
294
309
  }
295
310
  // its in the same directory, so always just the basename
296
- sourceMapOptions.sourceMapOutputFilename = path.basename(output);
297
- sourceMapOptions.sourceMapFullFilename = output + ".map";
311
+ if (output) {
312
+ sourceMapOptions.sourceMapOutputFilename = path.basename(output);
313
+ sourceMapOptions.sourceMapFullFilename = output + ".map";
314
+ }
298
315
  // its in the same directory, so always just the basename
299
- sourceMapOptions.sourceMapFilename = path.basename(sourceMapOptions.sourceMapFullFilename);
316
+ if ('sourceMapFullFilename' in sourceMapOptions) {
317
+ sourceMapOptions.sourceMapFilename = path.basename(sourceMapOptions.sourceMapFullFilename);
318
+ }
300
319
  } else if (options.sourceMap && !sourceMapFileInline) {
301
320
  var mapFilename = path.resolve(process.cwd(), sourceMapOptions.sourceMapFullFilename),
302
321
  mapDir = path.dirname(mapFilename),
@@ -316,7 +335,7 @@ function printUsage() {
316
335
  }
317
336
 
318
337
  if (sourceMapOptions.sourceMapRootpath === undefined) {
319
- var pathToMap = path.dirname(sourceMapFileInline ? output : sourceMapOptions.sourceMapFullFilename || '.'),
338
+ var pathToMap = path.dirname((sourceMapFileInline ? output : sourceMapOptions.sourceMapFullFilename) || '.'),
320
339
  pathToInput = path.dirname(sourceMapOptions.sourceMapInputFilename || '.');
321
340
  sourceMapOptions.sourceMapRootpath = path.relative(pathToMap, pathToInput);
322
341
  }
@@ -325,7 +344,7 @@ function printUsage() {
325
344
  console.error("lessc: no input files");
326
345
  console.error("");
327
346
  printUsage();
328
- currentErrorcode = 1;
347
+ process.exitCode = 1;
329
348
  return;
330
349
  }
331
350
 
@@ -345,7 +364,8 @@ function printUsage() {
345
364
 
346
365
  if (options.depends) {
347
366
  if (!outputbase) {
348
- console.log("option --depends requires an output path to be specified");
367
+ console.error("option --depends requires an output path to be specified");
368
+ process.exitCode = 1;
349
369
  return;
350
370
  }
351
371
  process.stdout.write(outputbase + ": ");
@@ -366,6 +386,7 @@ function printUsage() {
366
386
  }
367
387
  console.error('lessc: failed to create file ' + filename);
368
388
  console.error(description);
389
+ process.exitCode = 1;
369
390
  } else {
370
391
  less.logger.info('lessc: wrote ' + filename);
371
392
  }
@@ -397,6 +418,7 @@ function printUsage() {
397
418
  }
398
419
  console.error('lessc: failed to create file ' + output);
399
420
  console.error(description);
421
+ process.exitCode = 1;
400
422
  } else {
401
423
  less.logger.info('lessc: wrote ' + output);
402
424
  onSuccess();
@@ -421,7 +443,7 @@ function printUsage() {
421
443
  var parseLessFile = function (e, data) {
422
444
  if (e) {
423
445
  console.error("lessc: " + e.message);
424
- currentErrorcode = 1;
446
+ process.exitCode = 1;
425
447
  return;
426
448
  }
427
449
 
@@ -468,7 +490,7 @@ function printUsage() {
468
490
  },
469
491
  function(err) {
470
492
  less.writeError(err, options);
471
- currentErrorcode = 1;
493
+ process.exitCode = 1;
472
494
  });
473
495
  };
474
496
 
package/dist/less.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * Less - Leaner CSS v2.7.1
2
+ * Less - Leaner CSS v2.7.2
3
3
  * http://lesscss.org
4
4
  *
5
- * Copyright (c) 2009-2016, Alexis Sellier <self@cloudhead.net>
5
+ * Copyright (c) 2009-2017, Alexis Sellier <self@cloudhead.net>
6
6
  * Licensed under the Apache-2.0 License.
7
7
  *
8
8
  */
@@ -1718,41 +1718,33 @@ colorFunctions = {
1718
1718
  greyscale: function (color) {
1719
1719
  return colorFunctions.desaturate(color, new Dimension(100));
1720
1720
  },
1721
- contrast: function (color, color1, color2, threshold) {
1722
- // Return which of `color1` and `color2` has the greatest contrast with `color`
1723
- // according to the standard WCAG contrast ratio calculation.
1724
- // http://www.w3.org/TR/WCAG20/#contrast-ratiodef
1725
- // The threshold param is no longer used, in line with SASS.
1721
+ contrast: function (color, dark, light, threshold) {
1726
1722
  // filter: contrast(3.2);
1727
1723
  // should be kept as is, so check for color
1728
1724
  if (!color.rgb) {
1729
1725
  return null;
1730
1726
  }
1731
- if (typeof color1 === 'undefined') {
1732
- color1 = colorFunctions.rgba(0, 0, 0, 1.0);
1727
+ if (typeof light === 'undefined') {
1728
+ light = colorFunctions.rgba(255, 255, 255, 1.0);
1733
1729
  }
1734
- if (typeof color2 === 'undefined') {
1735
- color2 = colorFunctions.rgba(255, 255, 255, 1.0);
1730
+ if (typeof dark === 'undefined') {
1731
+ dark = colorFunctions.rgba(0, 0, 0, 1.0);
1736
1732
  }
1737
- var contrast1, contrast2;
1738
- var luma = color.luma();
1739
- var luma1 = color1.luma();
1740
- var luma2 = color2.luma();
1741
- // Calculate contrast ratios for each color
1742
- if (luma > luma1) {
1743
- contrast1 = (luma + 0.05) / (luma1 + 0.05);
1744
- } else {
1745
- contrast1 = (luma1 + 0.05) / (luma + 0.05);
1733
+ //Figure out which is actually light and dark!
1734
+ if (dark.luma() > light.luma()) {
1735
+ var t = light;
1736
+ light = dark;
1737
+ dark = t;
1746
1738
  }
1747
- if (luma > luma2) {
1748
- contrast2 = (luma + 0.05) / (luma2 + 0.05);
1739
+ if (typeof threshold === 'undefined') {
1740
+ threshold = 0.43;
1749
1741
  } else {
1750
- contrast2 = (luma2 + 0.05) / (luma + 0.05);
1742
+ threshold = number(threshold);
1751
1743
  }
1752
- if (contrast1 > contrast2) {
1753
- return color1;
1744
+ if (color.luma() < threshold) {
1745
+ return light;
1754
1746
  } else {
1755
- return color2;
1747
+ return dark;
1756
1748
  }
1757
1749
  },
1758
1750
  argb: function (color) {
@@ -2485,7 +2477,7 @@ module.exports = function(environment, fileManagers) {
2485
2477
  var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment;
2486
2478
 
2487
2479
  var less = {
2488
- version: [2, 7, 1],
2480
+ version: [2, 7, 2],
2489
2481
  data: require('./data'),
2490
2482
  tree: require('./tree'),
2491
2483
  Environment: (Environment = require("./environment/environment")),
@@ -5872,6 +5864,7 @@ var Node = require("./node"),
5872
5864
  var Comment = function (value, isLineComment, index, currentFileInfo) {
5873
5865
  this.value = value;
5874
5866
  this.isLineComment = isLineComment;
5867
+ this.index = index;
5875
5868
  this.currentFileInfo = currentFileInfo;
5876
5869
  this.allowRoot = true;
5877
5870
  };