vendor/lib/visitor/evaluator.js in stylus-source-0.19.2 vs vendor/lib/visitor/evaluator.js in stylus-source-0.19.3
- old
+ new
@@ -41,10 +41,11 @@
this.imports = options.imports || [];
this.functions = options.functions || {};
this.globals = options.globals || {};
this.paths = options.paths || [];
this.filename = options.filename;
+ this.includeCSS = options['include css'];
this.paths.push(dirname(options.filename || '.'));
this.stack.push(this.global = new Frame(root));
this.warnings = options.warn;
this.options = options;
this.calling = []; // TODO: remove, use stack
@@ -570,11 +571,13 @@
this.return = true;
var found
, root = this.root
, Parser = require('../parser')
- , path = this.visit(imported.path).first;
+ , path = this.visit(imported.path).first
+ , includeCSS = this.includeCSS
+ , literal;
this.return = _;
// url() passed
if ('url' == path.name) return imported;
@@ -582,13 +585,18 @@
// Enusre string
if (!path.string) throw new Error('@import string expected');
var name = path = path.string;
// Literal
- if (~path.indexOf('.css')) return imported;
- if (!~path.indexOf('.styl')) path += '.styl';
+ if (~path.indexOf('.css')) {
+ literal = true;
+ if (!includeCSS) return imported;
+ }
+ // support optional .styl
+ if (!literal && !~path.indexOf('.styl')) path += '.styl';
+
// Lookup
found = utils.lookup(path, this.paths, this.filename);
found = found || utils.lookup(join(name, 'index.styl'), this.paths, this.filename);
// Expose imports
@@ -602,11 +610,14 @@
// Parse the file
this.importStack.push(found);
nodes.filename = found;
- var str = fs.readFileSync(found, 'utf8')
- , block = new nodes.Block
+ var str = fs.readFileSync(found, 'utf8');
+ if (literal) return new nodes.Literal(str);
+
+ // parse
+ var block = new nodes.Block
, parser = new Parser(str, utils.merge({ root: block }, this.options));
try {
block = parser.parse();
} catch (err) {