mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Use shorter relative paths in error messages
This commit is contained in:
parent
6ee18dab21
commit
722a6339d6
@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2011 eBay Software Foundation
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -309,7 +309,7 @@ if (args.clean) {
|
||||
context.beginAsync();
|
||||
markoCompiler.compileFile(path, function(err, src) {
|
||||
if (err) {
|
||||
failed.push('Failed to compile "' + path + '". Error: ' + (err.stack || err));
|
||||
failed.push('Failed to compile "' + relPath(path) + '". Error: ' + (err.stack || err));
|
||||
context.endAsync(err);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ var TextNode = require('./TextNode');
|
||||
var ElementNode = require('./ElementNode');
|
||||
var CommentNode = require('./CommentNode');
|
||||
var charProps = require('char-props');
|
||||
var path = require('path');
|
||||
|
||||
var ieConditionalCommentRegExp = /^\[if [^]*?<!\[endif\]$/;
|
||||
// IE conditional comment format: <!--[if expression]> HTML <![endif]-->;
|
||||
@ -27,8 +28,17 @@ function isIEConditionalComment(comment) {
|
||||
return ieConditionalCommentRegExp.test(comment);
|
||||
}
|
||||
|
||||
function getRelativePath(absolutePath) {
|
||||
if (typeof window === 'undefined') {
|
||||
absolutePath = path.resolve(process.cwd(), absolutePath);
|
||||
return path.relative(process.cwd(), absolutePath);
|
||||
} else {
|
||||
return absolutePath;
|
||||
}
|
||||
}
|
||||
|
||||
function Pos(filePath, line, column) {
|
||||
this.filePath = filePath;
|
||||
this.filePath = getRelativePath(filePath);
|
||||
this.line = line;
|
||||
this.column = column;
|
||||
}
|
||||
|
||||
@ -28,6 +28,15 @@ var ElseNode = require('./ElseNode');
|
||||
var WithNode = require('./WithNode');
|
||||
var TagHandlerNode = require('./TagHandlerNode');
|
||||
var IncludeNode = require('./IncludeNode');
|
||||
var path = require('path');
|
||||
|
||||
function getTaglibPath(taglibPath) {
|
||||
if (typeof window === 'undefined') {
|
||||
return path.relative(process.cwd(), taglibPath);
|
||||
} else {
|
||||
return taglibPath;
|
||||
}
|
||||
}
|
||||
|
||||
var coreAttrHandlers = [
|
||||
[
|
||||
@ -375,7 +384,7 @@ module.exports = function transform(node, compiler, template) {
|
||||
if (tag) {
|
||||
// var isAttrForTaglib = compiler.taglibs.isTaglib(attrUri);
|
||||
//Tag doesn't allow dynamic attributes
|
||||
node.addError('The tag "' + tag.name + '" in taglib "' + tag.taglibId + '" does not support attribute "' + attr + '"');
|
||||
node.addError('The tag "' + tag.name + '" in taglib "' + getTaglibPath(tag.taglibId) + '" does not support attribute "' + attr + '"');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user