Skip to content

Commit

Permalink
Pull missed code merged into 3.x branch (#3212)
Browse files Browse the repository at this point in the history
* Add "grunt-cli" package to "devDependencies", so contibutors don't have to install grunt globally to run tests

* Add npm-scripts binding for grunt (npm run grunt -- [command])

* Update CONTRIBUTING.md to use `npm test` instead of `grunt test`

* LESS Importer: Throw some notice when a file is skipped over so you can see why it was skipped in the logs

* Update contributing doc
  • Loading branch information
matthew-dean committed Jun 16, 2018
1 parent 23569c9 commit 0de99e9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ We only accept issues that are bug reports or feature requests. Bugs must be iso
1. **Search for existing issues.** We get a lot of duplicate issues, and you'd help us out a lot by first checking if someone else has reported the same issue. Moreover, the issue may have already been resolved with a fix available.
2. **Create an isolated and reproducible test case.** Be sure the problem exists in Less.js's code with [reduced test cases](http://css-tricks.com/reduced-test-cases/) that should be included in each bug report.
3. **Test with the latest version**. We get a lot of issues that could be resolved by updating your version of Less.js.
3. **Include an example with source.** E.g. You can use [less2css.org](http://less2css.org/) to create a short test case.
4. **Share as much information as possible.** Include operating system and version. Describe how you use Less. If you use it in the browser, please include browser and version, and the version of Less.js you're using. Let us know if you're using the command line (`lessc`) or an external tool. And try to include steps to reproduce the bug.
5. If you have a solution or suggestion for how to fix the bug you're reporting, please include it, or make a pull request - don't assume the maintainers know how to fix it just because you do.
4. **Include an example with source.** E.g. You can use [Less Preview](http://lesscss.org/less-preview/) to create a short test case.
5. **Share as much information as possible.** Include operating system and version. Describe how you use Less. If you use it in the browser, please include browser and version, and the version of Less.js you're using. Let us know if you're using the command line (`lessc`) or an external tool. And try to include steps to reproduce the bug.
6. If you have a solution or suggestion for how to fix the bug you're reporting, please include it, or make a pull request - don't assume the maintainers know how to fix it just because you do.

Please report documentation issues in [the documentation project](https://github.com/less/less-docs).

Expand All @@ -35,7 +35,7 @@ _Pull requests are encouraged!_
* Start by adding a feature request to get feedback and see how your idea is received.
* If your pull request solves an existing issue, but it's different in some way, _please create a new issue_ and make sure to discuss it with the core contributors. Otherwise you risk your hard work being rejected.
* Do not change the **./dist/** folder, we do this when releasing
* _Please add tests_ for your work. Tests are invoked using `grunt test` command. It will run both node.js tests and browser ([PhantomJS](http://phantomjs.org/)) tests.
* _Please add tests_ for your work. Tests are invoked using `npm test` command. It will run both node.js tests and browser ([PhantomJS](http://phantomjs.org/)) tests.

### Coding Standards

Expand Down
14 changes: 8 additions & 6 deletions lib/less/import-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ var contexts = require("./contexts"),
Parser = require('./parser/parser'),
LessError = require('./less-error'),
utils = require('./utils'),
PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise;
PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise,
logger = require('./logger');

module.exports = function(environment) {

Expand All @@ -28,7 +29,7 @@ module.exports = function(environment) {
this.queue = []; // Files which haven't been imported yet
this.files = {}; // Holds the imported parse trees.
};

/**
* Add an import to be imported
* @param path - the raw path
Expand All @@ -49,14 +50,15 @@ module.exports = function(environment) {
var importedEqualsRoot = fullPath === importManager.rootFilename;
if (importOptions.optional && e) {
callback(null, {rules:[]}, false, null);
logger.info("The file " + fullPath + " was skipped because it was not found and the import was marked optional.");
}
else {
// 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; }
callback(e, root, importedEqualsRoot, fullPath);
}
Expand Down Expand Up @@ -121,10 +123,10 @@ module.exports = function(environment) {
} else if (importOptions.inline) {
fileParsedFunc(null, contents, resolvedFilename);
} else {

// import (multiple) parse trees apparently get altered and can't be cached.
// TODO: investigate why this is
if (importManager.files[resolvedFilename]
if (importManager.files[resolvedFilename]
&& !importManager.files[resolvedFilename].options.multiple
&& !importOptions.multiple) {

Expand All @@ -147,7 +149,7 @@ module.exports = function(environment) {
promise = pluginLoader.loadPlugin(path, currentFileInfo.currentDirectory, context, environment, fileManager);
}
else {
promise = fileManager.loadFile(path, currentFileInfo.currentDirectory, context, environment,
promise = fileManager.loadFile(path, currentFileInfo.currentDirectory, context, environment,
function(err, loadedFile) {
if (err) {
fileParsedFunc(err);
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"node": ">=4"
},
"scripts": {
"test": "grunt test"
"test": "grunt test",
"grunt": "grunt"
},
"optionalDependencies": {
"errno": "^0.1.1",
Expand All @@ -54,6 +55,7 @@
"git-rev": "^0.2.1",
"grunt": "~0.4.5",
"grunt-browserify": "^5.0.0",
"grunt-cli": "^1.2.0",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-connect": "^1.0.2",
Expand Down

0 comments on commit 0de99e9

Please sign in to comment.