-
-
Save cspotcode/19a42c629944f4e074d5 to your computer and use it in GitHub Desktop.
Reproduction of stylus/stylus#2125
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
npm install stylus | |
# Dump all output into log.txt | |
exec > >(tee -i zlog.txt) | |
exec 2>&1 | |
### Bug reproduction: | |
echo ==================================================================================== | |
echo ==================================================================================== | |
echo Using JS API, throws a useful error | |
node run.js proper | |
echo ==================================================================================== | |
echo ==================================================================================== | |
echo Using JS API, throws a confusing error | |
node run.js improper | |
echo ==================================================================================== | |
echo ==================================================================================== | |
echo Using CLI, throws a useful error | |
# both of these options are fine in isolation | |
node_modules/.bin/stylus --include-css index.styl | |
node_modules/.bin/stylus --resolve-url index.styl | |
echo ==================================================================================== | |
echo ==================================================================================== | |
echo Using CLI, throws a confusing error | |
# Used together, they cause an error | |
node_modules/.bin/stylus --include-css --resolve-url index.styl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const stylus = require('stylus'); | |
const fs = require('fs'); | |
switch(process.argv[2]) { | |
case 'proper': | |
// Proper error logging | |
stylus(fs.readFileSync('index.styl', 'utf-8')) | |
.set('filename', 'index.styl') | |
.set('include css', true) | |
.render(cb); | |
break; | |
case 'improper': | |
// Improper error logging | |
stylus(fs.readFileSync('index.styl', 'utf-8')) | |
.set('filename', 'index.styl') | |
.set('include css', true) | |
.define('url', stylus.resolver()) // I added this line which apparently breaks it. | |
.render(cb); | |
break; | |
default: | |
throw 'bad cli args'; | |
} | |
function cb(err, css) { | |
if(err) console.log(err); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// One styl file includes another... | |
@require './other' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... the other styl file has an error | |
foo {}} // <-- a syntax error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
==================================================================================== | |
==================================================================================== | |
Using JS API, throws a useful error | |
{ [ParseError: other.styl:2:8 | |
1| // ... the other styl file has an error | |
2| foo {}} // <-- a syntax error | |
-------------^ | |
3| | |
unexpected "}" | |
] | |
name: 'ParseError', | |
message: 'other.styl:2:8\n 1| // ... the other styl file has an error\n 2| foo {}} // <-- a syntax error\n-------------^\n 3| \n\nunexpected "}"\n', | |
filename: 'other.styl', | |
lineno: 2, | |
column: 8, | |
input: '// ... the other styl file has an error\nfoo {}} // <-- a syntax error\n' } | |
==================================================================================== | |
==================================================================================== | |
Using JS API, throws a confusing error | |
[TypeError: index.styl:3:1 | |
1| // One styl file includes another... | |
2| @require './other' | |
3| | |
------^ | |
Cannot read property 'nodeName' of undefined | |
] | |
==================================================================================== | |
==================================================================================== | |
Using CLI, throws a useful error | |
/Users/abradley/Desktop/stylus-error/node_modules/stylus/bin/stylus:662 | |
throw err; | |
^ | |
ParseError: other.styl:2:8 | |
1| // ... the other styl file has an error | |
2| foo {}} // <-- a syntax error | |
-------------^ | |
3| | |
unexpected "}" | |
at Parser.error (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/parser.js:259:11) | |
at Parser.stmt (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/parser.js:819:32) | |
at Parser.statement (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/parser.js:685:21) | |
at Parser.parse (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/parser.js:236:25) | |
at Evaluator.importFile (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/evaluator.js:74:20) | |
at Evaluator.visitImport (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/evaluator.js:906:27) | |
at Evaluator.Visitor.visit (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/index.js:28:40) | |
at Evaluator.visit (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/evaluator.js:156:18) | |
at Evaluator.visitRoot (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/evaluator.js:693:27) | |
at Evaluator.Visitor.visit (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/index.js:28:40) | |
/Users/abradley/Desktop/stylus-error/node_modules/stylus/bin/stylus:662 | |
throw err; | |
^ | |
ParseError: other.styl:2:8 | |
1| // ... the other styl file has an error | |
2| foo {}} // <-- a syntax error | |
-------------^ | |
3| | |
unexpected "}" | |
at Parser.error (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/parser.js:259:11) | |
at Parser.stmt (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/parser.js:819:32) | |
at Parser.statement (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/parser.js:685:21) | |
at Parser.parse (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/parser.js:236:25) | |
at Evaluator.importFile (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/evaluator.js:74:20) | |
at Evaluator.visitImport (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/evaluator.js:906:27) | |
at Evaluator.Visitor.visit (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/index.js:28:40) | |
at Evaluator.visit (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/evaluator.js:156:18) | |
at Evaluator.visitRoot (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/evaluator.js:693:27) | |
at Evaluator.Visitor.visit (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/index.js:28:40) | |
==================================================================================== | |
==================================================================================== | |
Using CLI, throws a confusing error | |
/Users/abradley/Desktop/stylus-error/node_modules/stylus/bin/stylus:662 | |
throw err; | |
^ | |
TypeError: index.styl:3:1 | |
1| // One styl file includes another... | |
2| @require './other' | |
3| | |
------^ | |
Cannot read property 'nodeName' of undefined | |
at Block.hasProperties (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/nodes/block.js:44:36) | |
at Normalizer.visitBlock (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/normalizer.js:212:12) | |
at Normalizer.Visitor.visit (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/index.js:28:40) | |
at Normalizer.visitRoot (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/normalizer.js:170:23) | |
at Normalizer.Visitor.visit (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/index.js:28:40) | |
at Normalizer.normalize (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/visitor/normalizer.js:53:18) | |
at Renderer.render (/Users/abradley/Desktop/stylus-error/node_modules/stylus/lib/renderer.js:90:22) | |
at /Users/abradley/Desktop/stylus-error/node_modules/stylus/bin/stylus:656:15 | |
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment