Skip to content

Commit 7d6dae0

Browse files
authored
Always use absolute URLs in stdout source maps (#1021)
Fixes #1020.
1 parent 69627fb commit 7d6dae0

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.26.8
2+
3+
* Fixes an error when emitting source maps to stdout.
4+
15
## 1.26.7
26

37
* No user-visible changes.

lib/src/executable/options.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ class ExecutableOptions {
388388
return extension == ".scss" || extension == ".sass" || extension == ".css";
389389
}
390390

391+
/// Returns whether we're writing to stdout instead of a file or files.
392+
bool get _writeToStdout =>
393+
sourcesToDestinations.length == 1 &&
394+
sourcesToDestinations.values.single == null;
395+
391396
/// Whether to emit a source map file.
392397
bool get emitSourceMap {
393398
if (!(_options['source-map'] as bool)) {
@@ -399,10 +404,7 @@ class ExecutableOptions {
399404
_fail("--embed-source-map isn't allowed with --no-source-map.");
400405
}
401406
}
402-
403-
var writeToStdout = sourcesToDestinations.length == 1 &&
404-
sourcesToDestinations.values.single == null;
405-
if (!writeToStdout) return _options['source-map'] as bool;
407+
if (!_writeToStdout) return _options['source-map'] as bool;
406408

407409
if (_ifParsed('source-map-urls') == 'relative') {
408410
_fail(
@@ -458,7 +460,7 @@ class ExecutableOptions {
458460
if (url.scheme.isNotEmpty && url.scheme != 'file') return url;
459461

460462
var path = p.fromUri(url);
461-
return p.toUri(_options['source-map-urls'] == 'relative'
463+
return p.toUri(_options['source-map-urls'] == 'relative' && !_writeToStdout
462464
? p.relative(path, from: p.dirname(destination))
463465
: p.absolute(path));
464466
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.26.7
2+
version: 1.26.8
33
description: A Sass implementation in Dart.
44
author: Sass Team
55
homepage: https://github.com/sass/dart-sass

test/cli/shared/source_maps.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,20 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
342342
expect(map, containsPair("file", "out.css"));
343343
});
344344
});
345+
346+
test("with stdout as the target", () async {
347+
var sass = await runSass(["--embed-source-map", "test.scss"]);
348+
expect(
349+
sass.stdout,
350+
emitsInOrder([
351+
"a {",
352+
" b: 3;",
353+
"}",
354+
"",
355+
startsWith("/*# sourceMappingURL=data:")
356+
]));
357+
await sass.shouldExit(0);
358+
});
345359
});
346360
}
347361

0 commit comments

Comments
 (0)