Skip to content
This repository was archived by the owner on May 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* Emit colors as `Value.HslColor` if that internal representation is
available.

* Add a `--version` flag that will print a `VersionResponse` as JSON, for ease
of human identification.

## 1.0.0-beta.10

* Support version 1.0.0-beta.12 of the Sass embedded protocol:
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ and importers.
[Dart Sass]: https://sass-lang.com/dart-sass
[Embedded Sass protocol]: https://github.com/sass/sass-embedded-protocol/blob/master/README.md#readme

### Usage

- `dart_sass_embedded` starts the compiler and listens on stdin.
- `dart_sass_embedded --version` prints `versionResponse` with `id = 0` in JSON and exits.

### Releases

Binary releases are available from the [GitHub release page]. We recommend that
Expand Down
8 changes: 8 additions & 0 deletions bin/dart_sass_embedded.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ import 'package:sass_embedded/src/utils.dart';

void main(List<String> args) {
if (args.isNotEmpty) {
if (args.first == "--version") {
var response = Dispatcher.versionResponse();
response.id = 0;
stdout.writeln(
JsonEncoder.withIndent(" ").convert(response.toProto3Json()));
return;
}

stderr.writeln(
"This executable is not intended to be executed with arguments.\n"
"See https://github.com/sass/embedded-protocol#readme for details.");
Expand Down
24 changes: 14 additions & 10 deletions lib/src/dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,10 @@ class Dispatcher {

switch (message.whichMessage()) {
case InboundMessage_Message.versionRequest:
_send(OutboundMessage()
..versionResponse = (OutboundMessage_VersionResponse()
..protocolVersion =
const String.fromEnvironment("protocol-version")
..compilerVersion =
const String.fromEnvironment("compiler-version")
..implementationVersion =
const String.fromEnvironment("implementation-version")
..implementationName = "Dart Sass"
..id = message.versionRequest.id));
var request = message.versionRequest;
var response = versionResponse();
response.id = request.id;
_send(OutboundMessage()..versionResponse = response);
break;

case InboundMessage_Message.compileRequest:
Expand Down Expand Up @@ -226,4 +220,14 @@ class Dispatcher {
break;
}
}

/// Creates a [OutboundMessage_VersionResponse]
static OutboundMessage_VersionResponse versionResponse() {
return OutboundMessage_VersionResponse()
..protocolVersion = const String.fromEnvironment("protocol-version")
..compilerVersion = const String.fromEnvironment("compiler-version")
..implementationVersion =
const String.fromEnvironment("implementation-version")
..implementationName = "Dart Sass";
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass_embedded
version: 1.0.0-dev
version: 1.0.0-beta.11
description: An implementation of the Sass embedded protocol using Dart Sass.
author: Sass Team
homepage: https://github.com/sass/dart-sass-embedded
Expand Down