mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
better error message when import missing a semi-colon or malformed.
This commit is contained in:
@@ -225,7 +225,7 @@ less.Parser = function Parser(env) {
|
||||
return oldi !== i || oldj !== j;
|
||||
}
|
||||
|
||||
function expect(arg, msg) {
|
||||
function expect(arg, msg, index) {
|
||||
// some older browsers return typeof 'function' for RegExp
|
||||
var result = (Object.prototype.toString.call(arg) === '[object Function]') ? arg.call(parsers) : $(arg);
|
||||
if (result) {
|
||||
@@ -1611,7 +1611,7 @@ less.Parser = function Parser(env) {
|
||||
//
|
||||
// @import "lib";
|
||||
//
|
||||
// Depending on our environemnt, importing is done differently:
|
||||
// Depending on our environment, importing is done differently:
|
||||
// In the browser, it's an XHR request, in Node, it would be a
|
||||
// file-system operation. The function used for importing is
|
||||
// stored in `import`, which we pass to the Import constructor.
|
||||
@@ -1619,22 +1619,27 @@ less.Parser = function Parser(env) {
|
||||
"import": function () {
|
||||
var path, features, index = i;
|
||||
|
||||
save();
|
||||
|
||||
var dir = $re(/^@import?\s+/);
|
||||
|
||||
var options = (dir ? this.importOptions() : null) || {};
|
||||
if (dir) {
|
||||
var options = (dir ? this.importOptions() : null) || {};
|
||||
|
||||
if (dir && (path = this.entities.quoted() || this.entities.url())) {
|
||||
features = this.mediaFeatures();
|
||||
if ($char(';')) {
|
||||
forget();
|
||||
if ((path = this.entities.quoted() || this.entities.url())) {
|
||||
features = this.mediaFeatures();
|
||||
|
||||
if (!$(';')) {
|
||||
i = index;
|
||||
error("missing semi-colon or unrecognised media features on import");
|
||||
}
|
||||
features = features && new(tree.Value)(features);
|
||||
return new(tree.Import)(path, features, options, index, env.currentFileInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
i = index;
|
||||
error("malformed import statement");
|
||||
}
|
||||
}
|
||||
|
||||
restore();
|
||||
},
|
||||
|
||||
importOptions: function() {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
ParseError: Unrecognised input in {path}import-no-semi.less on line 1, column 1:
|
||||
SyntaxError: missing semi-colon or unrecognised media features on import in {path}import-no-semi.less on line 1, column 1:
|
||||
1 @import "this-statement-is-invalid.less"
|
||||
|
||||
Reference in New Issue
Block a user