Fix @debug on stdin (#493)

This commit is contained in:
Natalie Weizenbaum 2018-10-10 15:05:23 -07:00 committed by GitHub
parent 89aa34c28e
commit 0620ccc19a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 3 deletions

View File

@ -1,3 +1,9 @@
## 1.14.2
### Command-Line Interface
* Don't crash when using `@debug` in a stylesheet passed on standard input.
## 1.14.1 ## 1.14.1
* Canonicalize escaped digits at the beginning of identifiers as hex escapes. * Canonicalize escaped digits at the beginning of identifiers as hex escapes.

View File

@ -44,8 +44,9 @@ class StderrLogger implements Logger {
} }
void debug(String message, SourceSpan span) { void debug(String message, SourceSpan span) {
stderr var url =
.write('${p.prettyUri(span.start.sourceUrl)}:${span.start.line + 1} '); span.start.sourceUrl == null ? '-' : p.prettyUri(span.start.sourceUrl);
stderr.write('$url:${span.start.line + 1} ');
stderr.write(color ? '\u001b[1mDebug\u001b[0m' : 'DEBUG'); stderr.write(color ? '\u001b[1mDebug\u001b[0m' : 'DEBUG');
stderr.writeln(': $message'); stderr.writeln(': $message');
} }

View File

@ -1,5 +1,5 @@
name: sass name: sass
version: 1.14.1 version: 1.14.2-dev
description: A Sass implementation in Dart. description: A Sass implementation in Dart.
author: Dart Team <misc@dartlang.org> author: Dart Team <misc@dartlang.org>
homepage: https://github.com/sass/dart-sass homepage: https://github.com/sass/dart-sass

View File

@ -202,6 +202,15 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
])); ]));
await sass.shouldExit(0); await sass.shouldExit(0);
}); });
// Regression test.
test("supports @debug", () async {
var sass = await runSass(["--no-source-map", "--stdin"]);
sass.stdin.writeln("@debug foo");
sass.stdin.close();
expect(sass.stderr, emitsInOrder(["-:1 DEBUG: foo"]));
await sass.shouldExit(0);
});
}); });
test("gracefully reports errors from stdin", () async { test("gracefully reports errors from stdin", () async {