mirror of
https://github.com/danog/dart-sass.git
synced 2024-11-30 04:39:03 +01:00
830bb3aab2
* Move Node tests on Windows to Travis Appveyor is flaky and can't be restarted by all team members, so moving everything to Travis is preferable if we can get it to work. * Actually use latest stable Node This should also workaround the issue with lts/* not working on Windows. * Use npm.cmd instead of raw npm on Windows * Use p.prettyUri() for Node API tests Co-authored-by: Natalie Weizenbaum <nweiz@google.com>
38 lines
1.3 KiB
Dart
38 lines
1.3 KiB
Dart
// Copyright 2018 Google Inc. Use of this source code is governed by an
|
|
// MIT-style license that can be found in the LICENSE file or at
|
|
// https://opensource.org/licenses/MIT.
|
|
|
|
import 'dart:async';
|
|
import 'dart:convert';
|
|
|
|
import 'package:path/path.dart' as p;
|
|
import 'package:test/test.dart';
|
|
|
|
import 'package:sass/src/io.dart';
|
|
|
|
/// A regular expression for matching the URL in a source map comment.
|
|
final _sourceMapCommentRegExp = RegExp(r"/\*# sourceMappingURL=(.*) \*/\s*$");
|
|
|
|
/// Returns a [Future] that waits long enough for modification times to be
|
|
/// different.
|
|
///
|
|
/// Windows (or at least Appveyor) seems to require a more coarse-grained time
|
|
/// than Unixes.
|
|
Future<void> get tick =>
|
|
Future.delayed(Duration(milliseconds: isWindows ? 1000 : 50));
|
|
|
|
/// Loads and decodes the source map embedded as a `data:` URI in [css].
|
|
///
|
|
/// Throws a [TestFailure] if [css] doesn't have such a source map.
|
|
Map<String, Object> embeddedSourceMap(String css) {
|
|
expect(css, matches(_sourceMapCommentRegExp));
|
|
|
|
var match = _sourceMapCommentRegExp.firstMatch(css);
|
|
var data = Uri.parse(match[1]).data;
|
|
expect(data.mimeType, equals("application/json"));
|
|
return jsonDecode(data.contentAsString()) as Map<String, Object>;
|
|
}
|
|
|
|
// Like `p.prettyUri()`, but for a non-URL path.
|
|
String prettyPath(String path) => p.prettyUri(p.toUri(path));
|