Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes to intl4x #955

Merged
merged 2 commits into from
Mar 11, 2025
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
4 changes: 4 additions & 0 deletions pkgs/intl4x/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.11.1

- Fix fraction digits parsing and allow no hook options key in the pubspec.

## 0.11.0

- Remove dep on package:js.
Expand Down
16 changes: 10 additions & 6 deletions pkgs/intl4x/lib/src/hook_helpers/build_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,27 @@ import 'package:yaml/yaml.dart' show YamlMap, loadYaml;
Future<BuildOptions?> getBuildOptions(String searchDir) async {
final map = await readOptionsFromPubspec(searchDir);
print('Reading build options from $map');
final buildOptions =
// ignore: avoid_dynamic_calls
BuildOptions.fromMap(map['intl4x'] as Map? ?? {});
final buildOptions = BuildOptions.fromMap(map?['intl4x'] as Map? ?? {});
print('Got build options: ${buildOptions.toJson()}');
return buildOptions;
}

Future<Map> readOptionsFromPubspec(String searchPath) async {
Future<YamlMap?> readOptionsFromPubspec(String searchPath) async {
File pubspec(Directory dir) => File(path.join(dir.path, 'pubspec.yaml'));

var directory = Directory(searchPath);
var counter = 0;
while (!pubspec(directory).existsSync()) {
directory = directory.parent;
counter++;
if (counter > 10) {
throw ArgumentError('Could not find pubspec at $searchPath');
}
}

// ignore: avoid_dynamic_calls
return loadYaml(pubspec(directory).readAsStringSync())['hook'] as YamlMap;
final pubspecYaml =
loadYaml(pubspec(directory).readAsStringSync()) as YamlMap;
return pubspecYaml['hook'] as YamlMap?;
}

enum BuildModeEnum { local, checkout, fetch }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ final class Digits {
roundingIncrement == null ||
((minimum != null || maximum != null) || minimum == maximum),
),
assert((minimum == null || maximum == null) || minimum < maximum);
assert((minimum == null || maximum == null) || minimum <= maximum);

const Digits.withSignificantDigits({int? minimum = 1, int? maximum = 21})
: fractionDigits = (null, null),
Expand Down
2 changes: 1 addition & 1 deletion pkgs/intl4x/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: intl4x
description: >-
A lightweight modular library for internationalization (i18n) functionality.
version: 0.11.0
version: 0.11.1
repository: https://github.com/dart-lang/i18n/tree/main/pkgs/intl4x
issue_tracker: https://github.com/dart-lang/i18n/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aintl4x

Expand Down