Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3181 #3200

Merged
merged 1 commit into from
Apr 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,17 @@ module.exports = function (grunt) {
command: 'node benchmark/index.js'
},
plugin: {
command: 'node bin/lessc --clean-css="--s1 --advanced" test/less/lazy-eval.less tmp/lazy-eval.css'
command: [
'node bin/lessc --clean-css="--s1 --advanced" test/less/lazy-eval.less tmp/lazy-eval.css',
'cd lib',
'node ../bin/lessc --clean-css="--s1 --advanced" ../test/less/lazy-eval.less ../tmp/lazy-eval.css'
].join(' && ')
},
"sourcemap-test": {
command: [
'node bin/lessc --source-map=test/sourcemaps/maps/import-map.map test/less/import.less test/sourcemaps/import.css',
'node bin/lessc --source-map test/less/sourcemaps/basic.less test/sourcemaps/basic.css'
].join('&&')
].join(' && ')
}
},

Expand Down Expand Up @@ -508,11 +512,6 @@ module.exports = function (grunt) {
'sauce-after-setup'
]);

// var sauceTests = [];
// browserTests.map(function(testName) {
// sauceTests.push('saucelabs-jasmine:' + testName);
// });

grunt.registerTask('sauce-after-setup', [
'saucelabs-jasmine:all',
'clean:sauce_log'
Expand All @@ -537,6 +536,9 @@ module.exports = function (grunt) {
// Run all tests
grunt.registerTask('test', testTasks);

// Run shell plugin test
grunt.registerTask('shell-plugin', ['shell:plugin']);

// Run all tests
grunt.registerTask('quicktest', testTasks.slice(0, -1));

Expand Down
9 changes: 6 additions & 3 deletions dist/less.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Less - Leaner CSS v3.0.1
* Less - Leaner CSS v3.0.3
* http://lesscss.org
*
* Copyright (c) 2009-2018, Alexis Sellier <[email protected]>
Expand Down Expand Up @@ -2728,7 +2728,10 @@ module.exports = function(environment) {
callback(null, {rules:[]}, false, null);
}
else {
if (!importManager.files[fullPath]) {
// Inline imports aren't cached here.
// If we start to cache them, please make sure they won't conflict with non-inline imports of the
// same name as they used to do before this comment and the condition below have been added.
if (!importManager.files[fullPath] && !importOptions.inline) {
importManager.files[fullPath] = { root: root, options: importOptions };
}
if (e && !importManager.error) { importManager.error = e; }
Expand Down Expand Up @@ -2843,7 +2846,7 @@ module.exports = function(environment, fileManagers) {
var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment;

var initial = {
version: [3, 0, 1],
version: [3, 0, 3],
data: require('./data'),
tree: require('./tree'),
Environment: (Environment = require("./environment/environment")),
Expand Down
6 changes: 3 additions & 3 deletions dist/less.min.js

Large diffs are not rendered by default.

41 changes: 32 additions & 9 deletions lib/less-node/file-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ FileManager.prototype.loadFile = function(filename, currentDirectory, options, e
self = this,
prefix = filename.slice(0, 1),
explicit = prefix === "." || prefix === "/",
result = null;
result = null,
isNodeModule = false,
npmPrefix = 'npm://';

options = options || {};

var paths = isAbsoluteFilename ? [''] : [currentDirectory];

if (options.paths) { paths.push.apply(paths, options.paths); }

// Search node_modules
if (!explicit) { paths.push.apply(paths, this.modulePaths); }

if (!isAbsoluteFilename && paths.indexOf('.') === -1) { paths.push('.'); }

var prefixes = options.prefixes || [''];
Expand Down Expand Up @@ -70,20 +69,44 @@ FileManager.prototype.loadFile = function(filename, currentDirectory, options, e
if (i < paths.length) {
(function tryPrefix(j) {
if (j < prefixes.length) {
isNodeModule = false;
fullFilename = fileParts.rawPath + prefixes[j] + fileParts.filename;

if (paths[i]) {
fullFilename = path.join(paths[i], fullFilename);
}

if (paths[i].indexOf('node_modules') > -1) {
if (!explicit && paths[i] === '.') {
try {
fullFilename = require.resolve(fullFilename);
isNodeModule = true;
}
catch (e) {
filenamesTried.push(npmPrefix + fullFilename);
tryWithExtension();
}
catch (e) {}
}
else {
tryWithExtension();
}

fullFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename;
function tryWithExtension() {
var extFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename;

if (extFilename !== fullFilename && !explicit && paths[i] === '.') {
try {
fullFilename = require.resolve(extFilename);
isNodeModule = true;
}
catch (e) {
filenamesTried.push(npmPrefix + extFilename);
fullFilename = extFilename;
}
}
else {
fullFilename = extFilename;
}
}

if (self.contents[fullFilename]) {
fulfill({ contents: self.contents[fullFilename], filename: fullFilename});
Expand All @@ -100,14 +123,14 @@ FileManager.prototype.loadFile = function(filename, currentDirectory, options, e
fulfill({ contents: data, filename: fullFilename});
}
catch (e) {
filenamesTried.push(fullFilename);
filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
return tryPrefix(j + 1);
}
}
else {
readFileArgs.push(function(e, data) {
if (e) {
filenamesTried.push(fullFilename);
filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
return tryPrefix(j + 1);
}
self.contents[fullFilename] = data;
Expand Down
3 changes: 0 additions & 3 deletions lib/less-node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ less.UrlFileManager = UrlFileManager;

// Set up options
less.options = require('../less/default-options')();
less.options.paths = [
path.join(process.cwd(), "node_modules")
];

// provide image-size functionality
require('./image-size')(less.environment);
Expand Down
2 changes: 1 addition & 1 deletion lib/less/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = function(environment, fileManagers) {
var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment;

var initial = {
version: [3, 0, 1],
version: [3, 0, 3],
data: require('./data'),
tree: require('./tree'),
Environment: (Environment = require("./environment/environment")),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "less",
"version": "3.0.2",
"version": "3.0.3",
"description": "Leaner CSS",
"homepage": "http://lesscss.org",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion test/less/errors/import-missing.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FileError: '{pathhref}file-does-not-exist.less' wasn't found{404status}{node}. Tried - {path}file-does-not-exist.less,{pathrel}file-does-not-exist.less,{nodepath}file-does-not-exist.less,file-does-not-exist.less{/node} in {path}import-missing.less on line 6, column 1:
FileError: '{pathhref}file-does-not-exist.less' wasn't found{404status}{node}. Tried - {path}file-does-not-exist.less,{pathrel}file-does-not-exist.less,npm://file-does-not-exist.less,file-does-not-exist.less{/node} in {path}import-missing.less on line 6, column 1:
5
6 @import "file-does-not-exist.less";