Skip to content

Less Importer: Throw some notice when a file is skipped #3065

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

Merged
merged 1 commit into from
May 26, 2018
Merged
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
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,11 +50,12 @@ 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 {
if (!importManager.files[fullPath]) {
importManager.files[fullPath] = { root: root, options: importOptions };
}
}
if (e && !importManager.error) { importManager.error = e; }
callback(e, root, importedEqualsRoot, fullPath);
}
Expand Down Expand Up @@ -118,10 +120,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 @@ -144,7 +146,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