Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
node.mtime = stat.mtime
this.paths.push(node.dirname)
// Avoid overflows from importing the same file over again
if (file === importStack[importStack.length - 1]) return nodes.null
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 && !this.resolveURL)
return new nodes.Literal(str.replace(/\r\n?/g, "\n"))
// parse
var block = new nodes.Block(),
parser = new Parser(str, utils.merge({ root: block }, this.options))
try {
block = parser.parse()
} catch (err) {
err.filename = file
err.lineno = parser.lexer.lineno
err.input = str
throw err
}
// Evaluate imported "root"
block.parent = this.root
if (file === importStack[importStack.length - 1]) return nodes.null;
if (this.options._imports) this.options._imports.push(node.clone());
// Parse the file
importStack.push(file);
nodes.filename = file;
var str;
if (this.cache.sources && this.cache.sources[file]) {
str = this.cache.sources[file];
} else {
str = fs.readFileSync(file, 'utf8');
}
if (literal && !this.resolveURL) return new nodes.Literal(str.replace(/\r\n?/g, '\n'));
// parse
var block = new nodes.Block
, parser = new Parser(str, utils.merge({ root: block }, this.options));
try {
block = parser.parse();
} catch (err) {
err.filename = file;
err.lineno = parser.lexer.lineno;
err.input = str;
throw err;
}
// Evaluate imported "root"
block.parent = this.root;