updated node modules

This commit is contained in:
Marc Wäckerlin
2016-09-12 14:54:14 +00:00
parent d7955e5d0f
commit d2455ba530
560 changed files with 94515 additions and 37458 deletions

View File

@@ -30,7 +30,6 @@ var Compiler = module.exports = function Compiler(root, options) {
this.firebug = options.firebug;
this.linenos = options.linenos;
this.spaces = options['indent spaces'] || 2;
this.includeCSS = options['include css'];
this.indents = 1;
Visitor.call(this, root);
this.stack = [];

View File

@@ -41,6 +41,15 @@ function importFile(node, file, literal) {
}
}
// Avoid overflows from importing the same file over again
if (~importStack.indexOf(file))
throw new Error('import loop has been found');
var str = fs.readFileSync(file, 'utf8');
// shortcut for empty files
if (!str.trim()) return nodes.null;
// Expose imports
node.path = file;
node.dirname = dirname(file);
@@ -49,17 +58,12 @@ function importFile(node, file, literal) {
node.mtime = stat.mtime;
this.paths.push(node.dirname);
// Avoid overflows from importing the same file over again
if (~importStack.indexOf(file))
throw new Error('import loop has been found');
if (this.options._imports) this.options._imports.push(node.clone());
// Parse the file
importStack.push(file);
nodes.filename = file;
var str = fs.readFileSync(file, 'utf8');
if (literal) {
literal = new nodes.Literal(str.replace(/\r\n?/g, '\n'));
literal.lineno = literal.column = 1;
@@ -76,7 +80,7 @@ function importFile(node, file, literal) {
var line = parser.lexer.lineno
, column = parser.lexer.column;
if (this.includeCSS && this.resolveURL) {
if (literal && this.includeCSS && this.resolveURL) {
this.warn('ParseError: ' + file + ':' + line + ':' + column + '. This file included as-is');
return literal;
} else {
@@ -213,10 +217,20 @@ Evaluator.prototype.populateGlobalScope = function(){
scope.add(node);
});
// expose url function
scope.add(new nodes.Ident(
'embedurl',
new nodes.Function('embedurl', require('../functions/url')({
limit: false
}))
));
// user-defined globals
var globals = this.globals;
Object.keys(globals).forEach(function(name){
scope.add(new nodes.Ident(name, globals[name]));
var val = globals[name];
if (!val.nodeName) val = new nodes.Literal(val);
scope.add(new nodes.Ident(name, val));
});
};
@@ -977,7 +991,7 @@ Evaluator.prototype.invokeFunction = function(fn, args, content){
var arg = args.map[node.name] || args.nodes[i++];
node = node.clone();
if (arg) {
arg.isEmpty ? args.nodes[i - 1] = node.val : node.val = arg;
arg.isEmpty ? args.nodes[i - 1] = this.visit(node) : node.val = arg;
} else {
args.push(node.val);
}
@@ -989,7 +1003,7 @@ Evaluator.prototype.invokeFunction = function(fn, args, content){
}
scope.add(node);
});
}, this);
// mixin block
if (content) scope.add(new nodes.Ident('block', content, true));

View File

@@ -38,8 +38,9 @@ var SourceMapper = module.exports = function SourceMapper(root, options){
this.basePath = sourcemap.basePath || '.';
this.inline = sourcemap.inline;
this.comment = sourcemap.comment;
if (extname(this.dest) === '.css') {
if (this.dest && extname(this.dest) === '.css') {
this.basename = basename(this.dest);
this.dest = dirname(this.dest);
} else {
this.basename = basename(this.filename, extname(this.filename)) + '.css';
}