less 3.0.0 → 3.0.1

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.
@@ -56,7 +56,7 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, imports,
56
56
  fileInfo: fileInfo
57
57
  };
58
58
  registry = functionRegistry.create();
59
-
59
+
60
60
  var registerPlugin = function(obj) {
61
61
  pluginObj = obj;
62
62
  };
@@ -67,7 +67,7 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, imports,
67
67
  } catch (e) {
68
68
  return new this.less.LessError(e, imports, filename);
69
69
  }
70
-
70
+
71
71
  if (!pluginObj) {
72
72
  pluginObj = localModule.exports;
73
73
  }
@@ -92,7 +92,7 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, imports,
92
92
  e.message = 'Error during @plugin call';
93
93
  return new this.less.LessError(e, imports, filename);
94
94
  }
95
-
95
+
96
96
  }
97
97
  else {
98
98
  return new this.less.LessError({ message: "Not a valid plugin" });
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @todo Document why this abstraction exists, and the relationship between
3
+ * environment, file managers, and plugin manager
4
+ */
5
+
1
6
  var logger = require("../logger");
2
7
  var environment = function(externalEnvironment, fileManagers) {
3
8
  this.fileManagers = fileManagers || [];
package/lib/less/index.js CHANGED
@@ -2,7 +2,7 @@ module.exports = function(environment, fileManagers) {
2
2
  var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment;
3
3
 
4
4
  var initial = {
5
- version: [3, 0, 0],
5
+ version: [3, 0, 1],
6
6
  data: require('./data'),
7
7
  tree: require('./tree'),
8
8
  Environment: (Environment = require("./environment/environment")),
@@ -18,10 +18,10 @@ var utils = require('./utils');
18
18
  * @prop {string[]} extract
19
19
  *
20
20
  * @param {Object} e - An error object to wrap around or just a descriptive object
21
- * @param {Object} importManager - An instance of ImportManager (see import-manager.js)
21
+ * @param {Object} fileContentMap - An object with file contents in 'contents' property (like importManager) @todo - move to fileManager?
22
22
  * @param {string} [currentFilename]
23
23
  */
24
- var LessError = module.exports = function LessError(e, importManager, currentFilename) {
24
+ var LessError = module.exports = function LessError(e, fileContentMap, currentFilename) {
25
25
  Error.call(this);
26
26
 
27
27
  var filename = e.filename || currentFilename;
@@ -29,13 +29,13 @@ var LessError = module.exports = function LessError(e, importManager, currentFil
29
29
  this.message = e.message;
30
30
  this.stack = e.stack;
31
31
 
32
- if (importManager && filename) {
33
- var input = importManager.contents[filename],
32
+ if (fileContentMap && filename) {
33
+ var input = fileContentMap.contents[filename],
34
34
  loc = utils.getLocation(e.index, input),
35
35
  line = loc.line,
36
36
  col = loc.column,
37
37
  callLine = e.call && utils.getLocation(e.call, input).line,
38
- lines = input.split('\n');
38
+ lines = input ? input.split('\n') : '';
39
39
 
40
40
  this.type = e.type || 'Syntax';
41
41
  this.filename = filename;
@@ -58,7 +58,7 @@ var LessError = module.exports = function LessError(e, importManager, currentFil
58
58
 
59
59
  this.callLine = callLine + 1;
60
60
  this.callExtract = lines[callLine];
61
-
61
+
62
62
  this.extract = [
63
63
  lines[this.line - 2],
64
64
  lines[this.line - 1],
package/lib/less/parse.js CHANGED
@@ -33,7 +33,7 @@ module.exports = function(environment, ParseTree, ImportManager) {
33
33
  } else {
34
34
  var context,
35
35
  rootFileInfo,
36
- pluginManager = new PluginManager(this, true);
36
+ pluginManager = new PluginManager(this, !options.reUsePluginManager);
37
37
 
38
38
  options.pluginManager = pluginManager;
39
39
 
@@ -79,7 +79,7 @@ module.exports = function(environment, ParseTree, ImportManager) {
79
79
  }
80
80
  });
81
81
  }
82
-
82
+
83
83
  new Parser(context, imports, rootFileInfo)
84
84
  .parse(input, function (e, root) {
85
85
  if (e) { return callback(e); }
@@ -151,5 +151,5 @@ PluginManager.prototype.getFileManagers = function() {
151
151
  return this.fileManagers;
152
152
  };
153
153
 
154
- //
154
+ //
155
155
  module.exports = PluginManagerFactory;
@@ -18,7 +18,7 @@ PluginLoader.prototype.loadPlugin = function(filename, basePath, context, enviro
18
18
  return new Promise(function(fulfill, reject) {
19
19
  fileManager.loadFile(filename, basePath, context, environment)
20
20
  .then(fulfill).catch(reject);
21
- });
21
+ });
22
22
  };
23
23
 
24
24
  module.exports = PluginLoader;
@@ -4,7 +4,7 @@ var path = require('path'),
4
4
  AbstractFileManager = require("../less/environment/abstract-file-manager.js");
5
5
 
6
6
  var FileManager = function() {
7
- this.files = {};
7
+ this.contents = {};
8
8
  };
9
9
 
10
10
  FileManager.prototype = new AbstractFileManager();
@@ -34,7 +34,7 @@ FileManager.prototype.loadFile = function(filename, currentDirectory, options, e
34
34
 
35
35
  // Search node_modules
36
36
  if (!explicit) { paths.push.apply(paths, this.modulePaths); }
37
-
37
+
38
38
  if (!isAbsoluteFilename && paths.indexOf('.') === -1) { paths.push('.'); }
39
39
 
40
40
  var prefixes = options.prefixes || [''];
@@ -82,11 +82,11 @@ FileManager.prototype.loadFile = function(filename, currentDirectory, options, e
82
82
  }
83
83
  catch (e) {}
84
84
  }
85
-
85
+
86
86
  fullFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename;
87
87
 
88
- if (self.files[fullFilename]) {
89
- fulfill({ contents: self.files[fullFilename], filename: fullFilename});
88
+ if (self.contents[fullFilename]) {
89
+ fulfill({ contents: self.contents[fullFilename], filename: fullFilename});
90
90
  }
91
91
  else {
92
92
  var readFileArgs = [fullFilename];
@@ -96,7 +96,7 @@ FileManager.prototype.loadFile = function(filename, currentDirectory, options, e
96
96
  if (options.syncImport) {
97
97
  try {
98
98
  var data = fs.readFileSync.apply(this, readFileArgs);
99
- self.files[fullFilename] = data;
99
+ self.contents[fullFilename] = data;
100
100
  fulfill({ contents: data, filename: fullFilename});
101
101
  }
102
102
  catch (e) {
@@ -106,11 +106,11 @@ FileManager.prototype.loadFile = function(filename, currentDirectory, options, e
106
106
  }
107
107
  else {
108
108
  readFileArgs.push(function(e, data) {
109
- if (e) {
109
+ if (e) {
110
110
  filenamesTried.push(fullFilename);
111
111
  return tryPrefix(j + 1);
112
112
  }
113
- self.files[fullFilename] = data;
113
+ self.contents[fullFilename] = data;
114
114
  fulfill({ contents: data, filename: fullFilename});
115
115
  });
116
116
  fs.readFile.apply(this, readFileArgs);
@@ -40,6 +40,7 @@ PluginLoader.prototype.loadPlugin = function(filename, basePath, context, enviro
40
40
  fulfill(data);
41
41
  }
42
42
  catch (e) {
43
+ console.log(e);
43
44
  reject(e);
44
45
  }
45
46
  }
@@ -47,7 +48,7 @@ PluginLoader.prototype.loadPlugin = function(filename, basePath, context, enviro
47
48
  reject(err);
48
49
  });
49
50
  });
50
-
51
+
51
52
  };
52
53
 
53
54
  module.exports = PluginLoader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "less",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Leaner CSS",
5
5
  "homepage": "http://lesscss.org",
6
6
  "author": {
@@ -895,7 +895,7 @@ PluginLoader.prototype.loadPlugin = function(filename, basePath, context, enviro
895
895
  return new Promise(function(fulfill, reject) {
896
896
  fileManager.loadFile(filename, basePath, context, environment)
897
897
  .then(fulfill).catch(reject);
898
- });
898
+ });
899
899
  };
900
900
 
901
901
  module.exports = PluginLoader;
@@ -1473,7 +1473,7 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, imports,
1473
1473
  fileInfo: fileInfo
1474
1474
  };
1475
1475
  registry = functionRegistry.create();
1476
-
1476
+
1477
1477
  var registerPlugin = function(obj) {
1478
1478
  pluginObj = obj;
1479
1479
  };
@@ -1484,7 +1484,7 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, imports,
1484
1484
  } catch (e) {
1485
1485
  return new this.less.LessError(e, imports, filename);
1486
1486
  }
1487
-
1487
+
1488
1488
  if (!pluginObj) {
1489
1489
  pluginObj = localModule.exports;
1490
1490
  }
@@ -1509,7 +1509,7 @@ AbstractPluginLoader.prototype.evalPlugin = function(contents, context, imports,
1509
1509
  e.message = 'Error during @plugin call';
1510
1510
  return new this.less.LessError(e, imports, filename);
1511
1511
  }
1512
-
1512
+
1513
1513
  }
1514
1514
  else {
1515
1515
  return new this.less.LessError({ message: "Not a valid plugin" });
@@ -1586,6 +1586,11 @@ module.exports = AbstractPluginLoader;
1586
1586
 
1587
1587
 
1588
1588
  },{"../functions/function-registry":26,"../less-error":36}],19:[function(require,module,exports){
1589
+ /**
1590
+ * @todo Document why this abstraction exists, and the relationship between
1591
+ * environment, file managers, and plugin manager
1592
+ */
1593
+
1589
1594
  var logger = require("../logger");
1590
1595
  var environment = function(externalEnvironment, fileManagers) {
1591
1596
  this.fileManagers = fileManagers || [];
@@ -2911,10 +2916,10 @@ var utils = require('./utils');
2911
2916
  * @prop {string[]} extract
2912
2917
  *
2913
2918
  * @param {Object} e - An error object to wrap around or just a descriptive object
2914
- * @param {Object} importManager - An instance of ImportManager (see import-manager.js)
2919
+ * @param {Object} fileContentMap - An object with file contents in 'contents' property (like importManager) @todo - move to fileManager?
2915
2920
  * @param {string} [currentFilename]
2916
2921
  */
2917
- var LessError = module.exports = function LessError(e, importManager, currentFilename) {
2922
+ var LessError = module.exports = function LessError(e, fileContentMap, currentFilename) {
2918
2923
  Error.call(this);
2919
2924
 
2920
2925
  var filename = e.filename || currentFilename;
@@ -2922,13 +2927,13 @@ var LessError = module.exports = function LessError(e, importManager, currentFil
2922
2927
  this.message = e.message;
2923
2928
  this.stack = e.stack;
2924
2929
 
2925
- if (importManager && filename) {
2926
- var input = importManager.contents[filename],
2930
+ if (fileContentMap && filename) {
2931
+ var input = fileContentMap.contents[filename],
2927
2932
  loc = utils.getLocation(e.index, input),
2928
2933
  line = loc.line,
2929
2934
  col = loc.column,
2930
2935
  callLine = e.call && utils.getLocation(e.call, input).line,
2931
- lines = input.split('\n');
2936
+ lines = input ? input.split('\n') : '';
2932
2937
 
2933
2938
  this.type = e.type || 'Syntax';
2934
2939
  this.filename = filename;
@@ -2951,7 +2956,7 @@ var LessError = module.exports = function LessError(e, importManager, currentFil
2951
2956
 
2952
2957
  this.callLine = callLine + 1;
2953
2958
  this.callExtract = lines[callLine];
2954
-
2959
+
2955
2960
  this.extract = [
2956
2961
  lines[this.line - 2],
2957
2962
  lines[this.line - 1],
@@ -3167,7 +3172,7 @@ module.exports = function(environment, ParseTree, ImportManager) {
3167
3172
  } else {
3168
3173
  var context,
3169
3174
  rootFileInfo,
3170
- pluginManager = new PluginManager(this, true);
3175
+ pluginManager = new PluginManager(this, !options.reUsePluginManager);
3171
3176
 
3172
3177
  options.pluginManager = pluginManager;
3173
3178
 
@@ -3213,7 +3218,7 @@ module.exports = function(environment, ParseTree, ImportManager) {
3213
3218
  }
3214
3219
  });
3215
3220
  }
3216
-
3221
+
3217
3222
  new Parser(context, imports, rootFileInfo)
3218
3223
  .parse(input, function (e, root) {
3219
3224
  if (e) { return callback(e); }
@@ -5755,7 +5760,7 @@ PluginManager.prototype.getFileManagers = function() {
5755
5760
  return this.fileManagers;
5756
5761
  };
5757
5762
 
5758
- //
5763
+ //
5759
5764
  module.exports = PluginManagerFactory;
5760
5765
 
5761
5766
  },{}],44:[function(require,module,exports){