Skip to content

Commit 2644c17

Browse files
authored
Small fixes to intl4x (#955)
* Small fixes to intl4x * Add changelog
1 parent 6d680ad commit 2644c17

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

pkgs/intl4x/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.11.1
2+
3+
- Fix fraction digits parsing and allow no hook options key in the pubspec.
4+
15
## 0.11.0
26

37
- Remove dep on package:js.

pkgs/intl4x/lib/src/hook_helpers/build_options.dart

+10-6
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,27 @@ import 'package:yaml/yaml.dart' show YamlMap, loadYaml;
1111
Future<BuildOptions?> getBuildOptions(String searchDir) async {
1212
final map = await readOptionsFromPubspec(searchDir);
1313
print('Reading build options from $map');
14-
final buildOptions =
15-
// ignore: avoid_dynamic_calls
16-
BuildOptions.fromMap(map['intl4x'] as Map? ?? {});
14+
final buildOptions = BuildOptions.fromMap(map?['intl4x'] as Map? ?? {});
1715
print('Got build options: ${buildOptions.toJson()}');
1816
return buildOptions;
1917
}
2018

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

2422
var directory = Directory(searchPath);
23+
var counter = 0;
2524
while (!pubspec(directory).existsSync()) {
2625
directory = directory.parent;
26+
counter++;
27+
if (counter > 10) {
28+
throw ArgumentError('Could not find pubspec at $searchPath');
29+
}
2730
}
2831

29-
// ignore: avoid_dynamic_calls
30-
return loadYaml(pubspec(directory).readAsStringSync())['hook'] as YamlMap;
32+
final pubspecYaml =
33+
loadYaml(pubspec(directory).readAsStringSync()) as YamlMap;
34+
return pubspecYaml['hook'] as YamlMap?;
3135
}
3236

3337
enum BuildModeEnum { local, checkout, fetch }

pkgs/intl4x/lib/src/number_format/number_format_options.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ final class Digits {
268268
roundingIncrement == null ||
269269
((minimum != null || maximum != null) || minimum == maximum),
270270
),
271-
assert((minimum == null || maximum == null) || minimum < maximum);
271+
assert((minimum == null || maximum == null) || minimum <= maximum);
272272

273273
const Digits.withSignificantDigits({int? minimum = 1, int? maximum = 21})
274274
: fractionDigits = (null, null),

pkgs/intl4x/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: intl4x
22
description: >-
33
A lightweight modular library for internationalization (i18n) functionality.
4-
version: 0.11.0
4+
version: 0.11.1
55
repository: https://github.com/dart-lang/i18n/tree/main/pkgs/intl4x
66
issue_tracker: https://github.com/dart-lang/i18n/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aintl4x
77

0 commit comments

Comments
 (0)