mirror of
https://github.com/danog/dart-sass.git
synced 2024-11-26 20:24:42 +01:00
Use Dart 2 constants
This commit is contained in:
parent
6ee8db39a6
commit
b949f9fe72
@ -1,3 +1,7 @@
|
||||
## 1.6.1
|
||||
|
||||
* No user-visible changes.
|
||||
|
||||
## 1.6.0
|
||||
|
||||
* Produce better errors when expected tokens are missing before a closing brace.
|
||||
|
@ -3,8 +3,8 @@
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:source_maps/source_maps.dart';
|
||||
|
||||
@ -128,8 +128,8 @@ String _writeSourceMap(
|
||||
sourceMap.urls[i] =
|
||||
options.sourceMapUrl(Uri.parse(url), destination).toString();
|
||||
}
|
||||
var sourceMapText = convert.json
|
||||
.encode(sourceMap.toJson(includeSourceContents: options.embedSources));
|
||||
var sourceMapText =
|
||||
jsonEncode(sourceMap.toJson(includeSourceContents: options.embedSources));
|
||||
|
||||
Uri url;
|
||||
if (options.embedSourceMap) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
// MIT-style license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
@ -20,7 +20,7 @@ class ImporterResult {
|
||||
/// acceptable as well. If no URL is supplied, a `data:` URL is generated
|
||||
/// automatically from [contents].
|
||||
Uri get sourceMapUrl =>
|
||||
_sourceMapUrl ?? new Uri.dataFromString(contents, encoding: convert.utf8);
|
||||
_sourceMapUrl ?? new Uri.dataFromString(contents, encoding: utf8);
|
||||
final Uri _sourceMapUrl;
|
||||
|
||||
/// Whether the stylesheet uses the indented syntax.
|
||||
|
@ -5,7 +5,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:js/js.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:source_span/source_span.dart';
|
||||
@ -128,7 +127,7 @@ Future<String> readStdin() async {
|
||||
completer.complete(contents);
|
||||
});
|
||||
// Node defaults all buffers to 'utf8'.
|
||||
var sink = convert.utf8.decoder.startChunkedConversion(innerSink);
|
||||
var sink = utf8.decoder.startChunkedConversion(innerSink);
|
||||
_stdin.on('data', allowInterop(([chunk]) {
|
||||
assert(chunk != null);
|
||||
sink.add(chunk as List<int>);
|
||||
|
@ -3,10 +3,10 @@
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io' as io;
|
||||
|
||||
import 'package:async/async.dart';
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:source_span/source_span.dart';
|
||||
import 'package:watcher/watcher.dart';
|
||||
@ -29,14 +29,14 @@ String readFile(String path) {
|
||||
var bytes = new io.File(path).readAsBytesSync();
|
||||
|
||||
try {
|
||||
return convert.utf8.decode(bytes);
|
||||
return utf8.decode(bytes);
|
||||
} on FormatException catch (error) {
|
||||
var decodedUntilError = convert.utf8
|
||||
.decode(bytes.sublist(0, error.offset), allowMalformed: true);
|
||||
var decodedUntilError =
|
||||
utf8.decode(bytes.sublist(0, error.offset), allowMalformed: true);
|
||||
var stringOffset = decodedUntilError.length;
|
||||
if (decodedUntilError.endsWith("<EFBFBD>")) stringOffset--;
|
||||
|
||||
var decoded = convert.utf8.decode(bytes, allowMalformed: true);
|
||||
var decoded = utf8.decode(bytes, allowMalformed: true);
|
||||
var sourceFile = new SourceFile.fromString(decoded, url: p.toUri(path));
|
||||
throw new SassException(
|
||||
"Invalid UTF-8.", sourceFile.location(stringOffset).pointSpan());
|
||||
@ -50,7 +50,7 @@ void deleteFile(String path) => new io.File(path).deleteSync();
|
||||
|
||||
Future<String> readStdin() async {
|
||||
var completer = new Completer<String>();
|
||||
completer.complete(await io.SYSTEM_ENCODING.decodeStream(io.stdin));
|
||||
completer.complete(await io.systemEncoding.decodeStream(io.stdin));
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ Iterable<String> listDir(String path) => new io.Directory(path)
|
||||
|
||||
DateTime modificationTime(String path) {
|
||||
var stat = io.FileStat.statSync(path);
|
||||
if (stat.type == io.FileSystemEntityType.NOT_FOUND) {
|
||||
if (stat.type == io.FileSystemEntityType.notFound) {
|
||||
throw new io.FileSystemException("File not found.", path);
|
||||
}
|
||||
return stat.modified;
|
||||
|
@ -3,10 +3,10 @@
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:js_util';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:js/js.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:tuple/tuple.dart';
|
||||
@ -362,7 +362,7 @@ RenderResult _newRenderResult(
|
||||
|
||||
var json = result.sourceMap
|
||||
.toJson(includeSourceContents: options.sourceMapContents);
|
||||
sourceMapBytes = utf8Encode(convert.json.encode(json));
|
||||
sourceMapBytes = utf8Encode(jsonEncode(json));
|
||||
|
||||
if (!isTruthy(options.omitSourceMapUrl)) {
|
||||
var url = options.sourceMapEmbed
|
||||
|
@ -2,8 +2,7 @@
|
||||
// MIT-style license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'package:dart2_constant/core.dart' as core;
|
||||
import 'package:dart2_constant/math.dart' as math;
|
||||
import 'dart:math';
|
||||
|
||||
import '../exception.dart';
|
||||
import '../util/number.dart';
|
||||
@ -85,25 +84,25 @@ final _conversions = {
|
||||
"deg": {
|
||||
"deg": 1,
|
||||
"grad": 9 / 10,
|
||||
"rad": 180 / math.pi,
|
||||
"rad": 180 / pi,
|
||||
"turn": 360,
|
||||
},
|
||||
"grad": {
|
||||
"deg": 10 / 9,
|
||||
"grad": 1,
|
||||
"rad": 200 / math.pi,
|
||||
"rad": 200 / pi,
|
||||
"turn": 400,
|
||||
},
|
||||
"rad": {
|
||||
"deg": math.pi / 180,
|
||||
"grad": math.pi / 200,
|
||||
"deg": pi / 180,
|
||||
"grad": pi / 200,
|
||||
"rad": 1,
|
||||
"turn": 2 * math.pi,
|
||||
"turn": 2 * pi,
|
||||
},
|
||||
"turn": {
|
||||
"deg": 1 / 360,
|
||||
"grad": 1 / 400,
|
||||
"rad": 1 / (2 * math.pi),
|
||||
"rad": 1 / (2 * pi),
|
||||
"turn": 1,
|
||||
},
|
||||
|
||||
@ -319,7 +318,7 @@ class SassNumber extends Value implements ext.SassNumber {
|
||||
if (other is SassNumber) {
|
||||
return _coerceNumber(other, (num1, num2) {
|
||||
if (num2 > 0) return num1 % num2;
|
||||
if (num2 == 0) return core.double.nan;
|
||||
if (num2 == 0) return double.nan;
|
||||
|
||||
// Dart has different mod-negative semantics than Ruby, and thus than
|
||||
// Sass.
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: sass
|
||||
version: 1.6.0
|
||||
version: 1.6.1
|
||||
description: A Sass implementation in Dart.
|
||||
author: Dart Team <misc@dartlang.org>
|
||||
homepage: https://github.com/sass/dart-sass
|
||||
@ -8,7 +8,7 @@ executables:
|
||||
dart-sass: sass
|
||||
|
||||
environment:
|
||||
sdk: '>=1.25.0-dev.35.0 <2.0.0'
|
||||
sdk: '>=1.25.0-dev.63.0 <2.0.0'
|
||||
|
||||
dependencies:
|
||||
args: ">=1.4.0 <2.0.0"
|
||||
@ -17,7 +17,6 @@ dependencies:
|
||||
cli_repl: "^0.1.3"
|
||||
collection: "^1.8.0"
|
||||
convert: "^2.0.1"
|
||||
dart2_constant: "^1.0.0"
|
||||
meta: "^1.1.0"
|
||||
package_resolver: "^1.0.0"
|
||||
path: "^1.6.0"
|
||||
|
@ -3,8 +3,8 @@
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:source_maps/source_maps.dart';
|
||||
import 'package:test/test.dart';
|
||||
@ -289,5 +289,4 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
|
||||
|
||||
/// Reads the file at [path] within [d.sandbox] and JSON-decodes it.
|
||||
Map<String, Object> _readJson(String path) =>
|
||||
convert.json.decode(readFile(p.join(d.sandbox, path)))
|
||||
as Map<String, Object>;
|
||||
jsonDecode(readFile(p.join(d.sandbox, path))) as Map<String, Object>;
|
||||
|
@ -3,8 +3,7 @@
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@ -30,15 +29,14 @@ Future deleteDirectory(String path) =>
|
||||
Future runHybridExpression(String expression, [message]) async {
|
||||
var channel = spawnHybridCode('''
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
|
||||
import 'package:stream_channel/stream_channel.dart';
|
||||
|
||||
hybridMain(StreamChannel channel, message) async {
|
||||
var result = await ${expression};
|
||||
channel.sink.add(_isJsonSafe(result) ? convert.json.encode(result) : 'null');
|
||||
channel.sink.add(_isJsonSafe(result) ? jsonEncode(result) : 'null');
|
||||
channel.sink.close();
|
||||
}
|
||||
|
||||
@ -56,5 +54,5 @@ Future runHybridExpression(String expression, [message]) async {
|
||||
}
|
||||
''', message: message);
|
||||
|
||||
return convert.json.decode((await channel.stream.first) as String);
|
||||
return jsonDecode((await channel.stream.first) as String);
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:js_util';
|
||||
|
||||
import 'package:dart2_constant/core.dart' as core;
|
||||
import 'package:js/js.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@ -181,7 +180,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
new Future.delayed(core.Duration.zero).then((_) {
|
||||
new Future.delayed(Duration.zero).then((_) {
|
||||
done(callConstructor(sass.types.Number, [1]));
|
||||
});
|
||||
})
|
||||
@ -201,7 +200,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
new Future.delayed(core.Duration.zero).then((_) {
|
||||
new Future.delayed(Duration.zero).then((_) {
|
||||
done(new JSError("aw beans"));
|
||||
});
|
||||
})
|
||||
@ -214,7 +213,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
new Future.delayed(core.Duration.zero).then((_) {
|
||||
new Future.delayed(Duration.zero).then((_) {
|
||||
done(null);
|
||||
});
|
||||
})
|
||||
@ -227,7 +226,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
new Future.delayed(core.Duration.zero).then((_) {
|
||||
new Future.delayed(Duration.zero).then((_) {
|
||||
done();
|
||||
});
|
||||
})
|
||||
@ -269,7 +268,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
new Future.delayed(core.Duration.zero).then((_) {
|
||||
new Future.delayed(Duration.zero).then((_) {
|
||||
done(callConstructor(sass.types.Number, [1]));
|
||||
});
|
||||
})
|
||||
@ -291,7 +290,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
new Future.delayed(core.Duration.zero).then((_) {
|
||||
new Future.delayed(Duration.zero).then((_) {
|
||||
done(new JSError("aw beans"));
|
||||
});
|
||||
})
|
||||
@ -305,7 +304,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
new Future.delayed(core.Duration.zero).then((_) {
|
||||
new Future.delayed(Duration.zero).then((_) {
|
||||
done(null);
|
||||
});
|
||||
})
|
||||
@ -319,7 +318,7 @@ void main() {
|
||||
data: "a {b: foo()}",
|
||||
functions: jsify({
|
||||
"foo": allowInterop((done) {
|
||||
new Future.delayed(core.Duration.zero).then((_) {
|
||||
new Future.delayed(Duration.zero).then((_) {
|
||||
done();
|
||||
});
|
||||
})
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:dart2_constant/core.dart' as core;
|
||||
import 'package:js/js.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:test/test.dart';
|
||||
@ -541,7 +540,7 @@ void main() {
|
||||
render(new RenderOptions(
|
||||
data: "@import 'foo'",
|
||||
importer: allowInterop((_, __, done) {
|
||||
new Future.delayed(core.Duration.zero).then((_) {
|
||||
new Future.delayed(Duration.zero).then((_) {
|
||||
done(new NodeImporterResult(contents: 'a {b: c}'));
|
||||
});
|
||||
}))),
|
||||
@ -553,7 +552,7 @@ void main() {
|
||||
renderError(new RenderOptions(
|
||||
data: "@import 'foo'",
|
||||
importer: allowInterop((_, __, done) {
|
||||
new Future.delayed(core.Duration.zero).then((_) {
|
||||
new Future.delayed(Duration.zero).then((_) {
|
||||
done(new JSError('oh no'));
|
||||
});
|
||||
}))),
|
||||
@ -595,7 +594,7 @@ void main() {
|
||||
render(new RenderOptions(
|
||||
data: "@import 'foo'",
|
||||
importer: allowInterop((_, __, done) {
|
||||
new Future.delayed(core.Duration.zero).then((_) {
|
||||
new Future.delayed(Duration.zero).then((_) {
|
||||
done(new NodeImporterResult(contents: 'a {b: c}'));
|
||||
});
|
||||
}),
|
||||
@ -630,7 +629,7 @@ void main() {
|
||||
renderError(new RenderOptions(
|
||||
data: "@import 'foo'",
|
||||
importer: allowInterop((_, __, done) {
|
||||
new Future.delayed(core.Duration.zero).then((_) {
|
||||
new Future.delayed(Duration.zero).then((_) {
|
||||
done(new JSError('oh no'));
|
||||
});
|
||||
}),
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:js/js.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:source_maps/source_maps.dart';
|
||||
@ -22,7 +21,7 @@ import 'api.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
/// A [Codec] that encodes and decodes UTF-8-encoded JSON.
|
||||
var _jsonUtf8 = convert.json.fuse(convert.utf8);
|
||||
var _jsonUtf8 = json.fuse(utf8);
|
||||
|
||||
void main() {
|
||||
setUpAll(ensureNpmPackage);
|
||||
@ -34,7 +33,7 @@ void main() {
|
||||
setUp(() {
|
||||
var result = sass.renderSync(new RenderOptions(
|
||||
data: "a {b: c}", sourceMap: true, outFile: "out.css"));
|
||||
css = convert.utf8.decode(result.css);
|
||||
css = utf8.decode(result.css);
|
||||
map = _jsonUtf8.decode(result.map) as Map<String, Object>;
|
||||
});
|
||||
|
||||
@ -136,21 +135,21 @@ void main() {
|
||||
var result = sass
|
||||
.renderSync(new RenderOptions(data: "a {b: c}", outFile: "out.css"));
|
||||
expect(result.map, isNull);
|
||||
expect(convert.utf8.decode(result.css), isNot(contains("/*#")));
|
||||
expect(utf8.decode(result.css), isNot(contains("/*#")));
|
||||
});
|
||||
|
||||
test("with sourceMap: false", () {
|
||||
var result = sass.renderSync(new RenderOptions(
|
||||
data: "a {b: c}", sourceMap: false, outFile: "out.css"));
|
||||
expect(result.map, isNull);
|
||||
expect(convert.utf8.decode(result.css), isNot(contains("/*#")));
|
||||
expect(utf8.decode(result.css), isNot(contains("/*#")));
|
||||
});
|
||||
|
||||
test("without outFile", () {
|
||||
var result =
|
||||
sass.renderSync(new RenderOptions(data: "a {b: c}", sourceMap: true));
|
||||
expect(result.map, isNull);
|
||||
expect(convert.utf8.decode(result.css), isNot(contains("/*#")));
|
||||
expect(utf8.decode(result.css), isNot(contains("/*#")));
|
||||
});
|
||||
});
|
||||
|
||||
@ -204,7 +203,7 @@ void main() {
|
||||
outFile: "out.css",
|
||||
omitSourceMapUrl: true));
|
||||
expect(result.map, isNotNull);
|
||||
expect(convert.utf8.decode(result.css), isNot(contains("/*#")));
|
||||
expect(utf8.decode(result.css), isNot(contains("/*#")));
|
||||
});
|
||||
|
||||
group("with a string sourceMap", () {
|
||||
@ -212,15 +211,15 @@ void main() {
|
||||
var result = sass.renderSync(new RenderOptions(
|
||||
data: "a {b: c}", sourceMap: "map", outFile: "out.css"));
|
||||
expect(result.map, isNotNull);
|
||||
expect(convert.utf8.decode(result.css),
|
||||
endsWith("\n\n/*# sourceMappingURL=map */"));
|
||||
expect(
|
||||
utf8.decode(result.css), endsWith("\n\n/*# sourceMappingURL=map */"));
|
||||
});
|
||||
|
||||
test("makes the source map comment relative to the outfile", () {
|
||||
var result = sass.renderSync(new RenderOptions(
|
||||
data: "a {b: c}", sourceMap: "map", outFile: "dir/out.css"));
|
||||
expect(result.map, isNotNull);
|
||||
expect(convert.utf8.decode(result.css),
|
||||
expect(utf8.decode(result.css),
|
||||
endsWith("\n\n/*# sourceMappingURL=../map */"));
|
||||
});
|
||||
|
||||
@ -235,8 +234,8 @@ void main() {
|
||||
var result = sass.renderSync(new RenderOptions(
|
||||
data: "a {b: c}", sourceMap: p.absolute("map"), outFile: "out.css"));
|
||||
expect(result.map, isNotNull);
|
||||
expect(convert.utf8.decode(result.css),
|
||||
endsWith("\n\n/*# sourceMappingURL=map */"));
|
||||
expect(
|
||||
utf8.decode(result.css), endsWith("\n\n/*# sourceMappingURL=map */"));
|
||||
});
|
||||
|
||||
test("makes the sources list relative to the map location", () async {
|
||||
@ -285,7 +284,7 @@ void main() {
|
||||
outFile: "out.css",
|
||||
sourceMapEmbed: true));
|
||||
|
||||
var map = embeddedSourceMap(convert.utf8.decode(result.css));
|
||||
var map = embeddedSourceMap(utf8.decode(result.css));
|
||||
expect(map, equals(_jsonUtf8.decode(result.map)));
|
||||
});
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:js/js.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@ -39,7 +39,7 @@ Future<String> render(RenderOptions options) {
|
||||
sass.render(options,
|
||||
allowInterop(Zone.current.bindBinaryCallbackGuarded((error, result) {
|
||||
expect(error, isNull);
|
||||
completer.complete(convert.utf8.decode(result.css));
|
||||
completer.complete(utf8.decode(result.css));
|
||||
})));
|
||||
return completer.future;
|
||||
}
|
||||
@ -58,7 +58,7 @@ Future<RenderError> renderError(RenderOptions options) {
|
||||
|
||||
/// Returns the result of rendering via [options] as a string.
|
||||
String renderSync(RenderOptions options) =>
|
||||
convert.utf8.decode(sass.renderSync(options).css);
|
||||
utf8.decode(sass.renderSync(options).css);
|
||||
|
||||
/// Asserts that rendering via [options] produces an error, and returns that
|
||||
/// error.
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
@TestOn('vm')
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
@ -19,7 +19,7 @@ void main() {
|
||||
var source = new File(sourcePath).readAsStringSync();
|
||||
var target = new File(targetPath).readAsStringSync();
|
||||
|
||||
var hash = sha1.convert(convert.utf8.encode(source));
|
||||
var hash = sha1.convert(utf8.encode(source));
|
||||
if (!target.contains("Checksum: $hash")) {
|
||||
fail("$targetPath is out-of-date.\n"
|
||||
"Run pub run grinder to update it.");
|
||||
|
@ -3,8 +3,8 @@
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'package:sass/src/io.dart';
|
||||
@ -30,5 +30,5 @@ Map<String, Object> embeddedSourceMap(String css) {
|
||||
var match = _sourceMapCommentRegExp.firstMatch(css);
|
||||
var data = Uri.parse(match[1]).data;
|
||||
expect(data.mimeType, equals("application/json"));
|
||||
return convert.json.decode(data.contentAsString()) as Map<String, Object>;
|
||||
return jsonDecode(data.contentAsString()) as Map<String, Object>;
|
||||
}
|
||||
|
@ -3,10 +3,10 @@
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:charcode/charcode.dart';
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:grinder/grinder.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:path/path.dart' as p;
|
||||
@ -28,7 +28,7 @@ github_release() async {
|
||||
"content-type": "application/json",
|
||||
"authorization": authorization
|
||||
},
|
||||
body: convert.json.encode({
|
||||
body: jsonEncode({
|
||||
"tag_name": version,
|
||||
"name": "Dart Sass $version",
|
||||
"prerelease": new Version.parse(version).isPreRelease,
|
||||
@ -41,7 +41,7 @@ github_release() async {
|
||||
log("Released Dart Sass $version to GitHub.");
|
||||
}
|
||||
|
||||
var uploadUrl = convert.json
|
||||
var uploadUrl = json
|
||||
.decode(response.body)["upload_url"]
|
||||
// Remove the URL template.
|
||||
.replaceFirst(new RegExp(r"\{[^}]+\}$"), "");
|
||||
@ -132,5 +132,5 @@ String _lastChangelogSection() {
|
||||
String _githubAuthorization() {
|
||||
var username = environment("GITHUB_USER");
|
||||
var token = environment("GITHUB_AUTH");
|
||||
return "Basic ${convert.base64.encode(convert.utf8.encode("$username:$token"))}";
|
||||
return "Basic ${base64.encode(utf8.encode("$username:$token"))}";
|
||||
}
|
||||
|
@ -3,9 +3,9 @@
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:grinder/grinder.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
@ -23,7 +23,7 @@ update_homebrew() async {
|
||||
var process = await Process.start("git",
|
||||
["archive", "--prefix=dart-sass-$version/", "--format=tar.gz", version]);
|
||||
var digest = await sha256.bind(process.stdout).first;
|
||||
var stderr = await convert.utf8.decodeStream(process.stderr);
|
||||
var stderr = await utf8.decodeStream(process.stderr);
|
||||
if ((await process.exitCode) != 0) {
|
||||
fail('git archive "$version" failed:\n$stderr');
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
// MIT-style license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:charcode/charcode.dart';
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:grinder/grinder.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:node_preamble/preamble.dart' as preamble;
|
||||
@ -65,9 +65,8 @@ npm_release_package() => _npm(release: true);
|
||||
/// --trust-type-annotations. Otherwise, it compiles unminified with pessimistic
|
||||
/// type checks.
|
||||
void _npm({@required bool release}) {
|
||||
var json =
|
||||
convert.json.decode(new File('package/package.json').readAsStringSync())
|
||||
as Map<String, dynamic>;
|
||||
var json = jsonDecode(new File('package/package.json').readAsStringSync())
|
||||
as Map<String, dynamic>;
|
||||
json['version'] = version;
|
||||
|
||||
_writeNpmPackage('build/npm', json);
|
||||
@ -86,7 +85,7 @@ void _writeNpmPackage(String destination, Map<String, dynamic> json) {
|
||||
|
||||
log("copying package/package.json to $destination");
|
||||
new File(p.join(destination, 'package.json'))
|
||||
.writeAsStringSync(convert.json.encode(json));
|
||||
.writeAsStringSync(jsonEncode(json));
|
||||
|
||||
copy(new File(p.join('package', 'sass.js')), dir);
|
||||
copy(new File(p.join('build', 'sass.dart.js')), dir);
|
||||
|
@ -6,7 +6,6 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:archive/archive.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:grinder/grinder.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:http/http.dart' as http;
|
||||
|
@ -2,12 +2,12 @@
|
||||
// MIT-style license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:analyzer/analyzer.dart';
|
||||
import 'package:analyzer/dart/ast/token.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:dart_style/dart_style.dart';
|
||||
import 'package:grinder/grinder.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
@ -72,7 +72,7 @@ class _Visitor extends RecursiveAstVisitor {
|
||||
// DO NOT EDIT. This file was generated from ${p.basename(path)}.
|
||||
// See tool/synchronize.dart for details.
|
||||
//
|
||||
// Checksum: ${sha1.convert(convert.utf8.encode(_source))}
|
||||
// Checksum: ${sha1.convert(utf8.encode(_source))}
|
||||
""");
|
||||
|
||||
if (p.basename(path) == 'async_evaluate.dart') {
|
||||
|
@ -3,10 +3,10 @@
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:archive/archive.dart';
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:grinder/grinder.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:pub_semver/pub_semver.dart';
|
||||
@ -55,7 +55,7 @@ ArchiveFile fileFromBytes(String path, List<int> data,
|
||||
/// If [executable] is `true`, this marks the file as executable.
|
||||
ArchiveFile fileFromString(String path, String contents,
|
||||
{bool executable: false}) =>
|
||||
fileFromBytes(path, convert.utf8.encode(contents), executable: executable);
|
||||
fileFromBytes(path, utf8.encode(contents), executable: executable);
|
||||
|
||||
/// Creates an [ArchiveFile] at the archive path [target] from the local file at
|
||||
/// [source].
|
||||
|
@ -2,12 +2,12 @@
|
||||
// MIT-style license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:analyzer/analyzer.dart';
|
||||
import 'package:analyzer/dart/ast/token.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:dart2_constant/convert.dart' as convert;
|
||||
import 'package:dart_style/dart_style.dart';
|
||||
import 'package:grinder/grinder.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
@ -81,7 +81,7 @@ class _Visitor extends RecursiveAstVisitor {
|
||||
// DO NOT EDIT. This file was generated from ${p.basename(_sourcePath)}.
|
||||
// See tool/synchronize.dart for details.
|
||||
//
|
||||
// Checksum: ${sha1.convert(convert.utf8.encode(_source))}
|
||||
// Checksum: ${sha1.convert(utf8.encode(_source))}
|
||||
""");
|
||||
|
||||
if (p.basename(_sourcePath) == 'async_evaluate.dart') {
|
||||
|
Loading…
Reference in New Issue
Block a user