less 3.11.2 → 3.11.3

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.
@@ -26,6 +26,7 @@ export default environment => {
26
26
  this.context = context;
27
27
  // Deprecated? Unused outside of here, could be useful.
28
28
  this.queue = []; // Files which haven't been imported yet
29
+ this.files = []; // List of files imported
29
30
  }
30
31
 
31
32
  /**
@@ -51,6 +52,10 @@ export default environment => {
51
52
  logger.info(`The file ${fullPath} was skipped because it was not found and the import was marked optional.`);
52
53
  }
53
54
  else {
55
+ const files = importManager.files
56
+ if (files.indexOf(fullPath) === -1) {
57
+ files.push(fullPath)
58
+ }
54
59
  if (e && !importManager.error) { importManager.error = e; }
55
60
  callback(e, root, importedEqualsRoot, fullPath);
56
61
  }
package/lib/less/index.js CHANGED
@@ -42,7 +42,7 @@ export default (environment, fileManagers) => {
42
42
  * It's not clear what should / must be public and why.
43
43
  */
44
44
  const initial = {
45
- version: [3, 11, 2],
45
+ version: [3, 11, 3],
46
46
  data,
47
47
  tree,
48
48
  Environment,
@@ -52,12 +52,8 @@ export default SourceMapBuilder => {
52
52
  result.map = sourceMapBuilder.getExternalSourceMap();
53
53
  }
54
54
 
55
- result.imports = [];
56
- for (const file in this.imports.files) {
57
- if (this.imports.files.hasOwnProperty(file) && file !== this.imports.rootFilename) {
58
- result.imports.push(file);
59
- }
60
- }
55
+ const rootFilename = this.imports.rootFilename
56
+ result.imports = this.imports.files.filter(file => file !== rootFilename);
61
57
  return result;
62
58
  }
63
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "less",
3
- "version": "3.11.2",
3
+ "version": "3.11.3",
4
4
  "description": "Leaner CSS",
5
5
  "homepage": "http://lesscss.org",
6
6
  "author": {
package/test/index.js CHANGED
@@ -48,6 +48,12 @@ var testMap = [
48
48
  }
49
49
  return path.join('test/sourcemaps', filename) + '.json';
50
50
  }],
51
+
52
+ [{math: 'strict', strictUnits: true, globalVars: true }, 'import/json/',
53
+ lessTester.testImports, null, true,
54
+ function(filename, type, baseFolder) {
55
+ return path.join(baseFolder, filename) + '.json';
56
+ }],
51
57
  [{math: 'strict', strictUnits: true, sourceMap: {sourceMapFileInline: true}},
52
58
  'sourcemaps-empty/', lessTester.testEmptySourcemap],
53
59
  [{globalVars: true, banner: '/**\n * Test\n */\n'}, 'globalVars/',
@@ -0,0 +1,11 @@
1
+ [
2
+ "{path}/import/import-test-a.less",
3
+ "{path}/import/import-test-b.less",
4
+ "{path}/import/deeper/url-import.less",
5
+ "{path}/import/urls.less",
6
+ "{path}/import/import-test-c.less",
7
+ "{path}/import/deeper/deeper-2/url-import.less",
8
+ "{path}/import/deeper/deeper-2/url-import-2.less",
9
+ "{path}/import/import-test-f.less",
10
+ "{path}/import/import-test-e.less"
11
+ ]
@@ -0,0 +1 @@
1
+ @import "../import-test-a";
package/test/less-test.js CHANGED
@@ -140,6 +140,42 @@ module.exports = function() {
140
140
  }
141
141
  }
142
142
 
143
+ function testImports(name, err, compiledLess, doReplacements, sourcemap, baseFolder, imports) {
144
+ if (err) {
145
+ fail('ERROR: ' + (err && err.message));
146
+ return;
147
+ }
148
+
149
+ function stringify(str) {
150
+ return JSON.stringify(imports, null, ' ')
151
+ }
152
+
153
+ /** Imports are not sorted */
154
+ const importsString = stringify(imports.sort())
155
+
156
+ fs.readFile(path.join('test/less/', name) + '.json', 'utf8', function (e, expectedImports) {
157
+ if (e) {
158
+ fail('ERROR: ' + (e && e.message));
159
+ return;
160
+ }
161
+ process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
162
+ expectedImports = stringify(JSON.parse(expectedImports).sort());
163
+ expectedImports = globalReplacements(expectedImports, baseFolder);
164
+
165
+ if (expectedImports === importsString) {
166
+ ok('OK');
167
+ } else if (err) {
168
+ fail('ERROR: ' + (err && err.message));
169
+ if (isVerbose) {
170
+ process.stdout.write('\n');
171
+ process.stdout.write(err.stack + '\n');
172
+ }
173
+ } else {
174
+ difference('FAIL', expectedImports, importsString);
175
+ }
176
+ });
177
+ }
178
+
143
179
  function testErrors(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
144
180
  fs.readFile(path.join(baseFolder, name) + '.txt', 'utf8', function (e, expectedErr) {
145
181
  process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
@@ -303,8 +339,13 @@ module.exports = function() {
303
339
  }
304
340
  doubleCallCheck = (new Error()).stack;
305
341
 
342
+ /**
343
+ * @todo - refactor so the result object is sent to the verify function
344
+ */
306
345
  if (verifyFunction) {
307
- var verificationResult = verifyFunction(name, err, result && result.css, doReplacements, result && result.map, baseFolder);
346
+ var verificationResult = verifyFunction(
347
+ name, err, result && result.css, doReplacements, result && result.map, baseFolder, result && result.imports
348
+ );
308
349
  release();
309
350
  return verificationResult;
310
351
  }
@@ -362,7 +403,7 @@ module.exports = function() {
362
403
  process.stdout.write(stylize(msg, 'yellow') + '\n');
363
404
  failedTests++;
364
405
 
365
- diff(left, right);
406
+ diff(left || '', right || '');
366
407
  endTest();
367
408
  }
368
409
 
@@ -452,6 +493,7 @@ module.exports = function() {
452
493
  testSyncronous: testSyncronous,
453
494
  testErrors: testErrors,
454
495
  testSourcemap: testSourcemap,
496
+ testImports: testImports,
455
497
  testEmptySourcemap: testEmptySourcemap,
456
498
  testNoOptions: testNoOptions,
457
499
  prepBomTest: prepBomTest,