Skip to content

Commit

Permalink
Fix dart (#87)
Browse files Browse the repository at this point in the history
* Add version

* Fix bug

* Add locale
  • Loading branch information
mosuem authored Aug 10, 2023
1 parent 3334919 commit f096121
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion executors/dart_web/bin/collator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ String testCollationShort(String jsonEncoded) {
var json =
jsonDecode(jsonEncoded); // For the moment, use strings for easier interop
// Global default locale
var testLocale = '';
var testLocale = 'en';
Map<String, dynamic> outputLine;

// Set up collator object with optional locale and testOptions.
Expand Down
18 changes: 18 additions & 0 deletions executors/dart_web/bin/make_runnable_by_node.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:io';

import 'package:pubspec_lock_parse/pubspec_lock_parse.dart';

Future<void> main(List<String> args) async {
var name = 'collatorDart';
var compile = await Process.run('dart', [
Expand All @@ -12,6 +14,22 @@ Future<void> main(List<String> args) async {
print(compile.stderr);

prepareOutFile(name, ['testCollationShort']);

setVersionFile();
}

void setVersionFile() {
var lockStr = File('pubspec.lock').readAsStringSync();

final lockfile = PubspecLock.parse(lockStr);

var version = lockfile.packages['intl4x']?.version;
if (version != null) {
File('out/version.js').writeAsStringSync('''
const dartVersion = "${version.canonicalizedVersion}";
module.exports = { dartVersion };
''');
}
}

/// Prepare the file to export `testCollationShort`
Expand Down
4 changes: 3 additions & 1 deletion executors/dart_web/out/executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


let collator = require('./collator.js')
const { dartVersion } = require('./version.js')

/**
* TODOs:
Expand Down Expand Up @@ -120,9 +121,10 @@ rl.on('line', function (line) {
if (line == "#VERSION") {
// JSON output of the test enviroment.
let versionJson = {
'platform': 'NodeJS',
'platform': 'Dart Web',
'platformVersion': process.version,
'icuVersion': process.versions.icu,
'intlVersion': dartVersion,
};

// TODO: Make this more specific JSON info.
Expand Down
2 changes: 2 additions & 0 deletions executors/dart_web/out/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const dartVersion = "0.4.0";
module.exports = { dartVersion };
1 change: 1 addition & 0 deletions executors/dart_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ environment:
# Add regular dependencies here.
dependencies:
intl4x: ^0.4.0
pubspec_lock_parse: ^2.2.0

dev_dependencies:
lints: ^2.0.0
Expand Down

0 comments on commit f096121

Please sign in to comment.