Skip to content

Commit 9a55ab9

Browse files
authored
Allow modification of a BuildOutput's raw dependencies (#169)
1 parent 98c0ee8 commit 9a55ab9

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

pkgs/native_assets_cli/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.3.2
2+
3+
- Fixed an issue where `Depenendencies.dependencies` could not be
4+
modified when expected to.
5+
16
## 0.3.1
27

38
- Added `Target.androidRiscv64`.

pkgs/native_assets_cli/lib/src/model/build_output.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ class BuildOutput {
3333
Metadata? metadata,
3434
}) : timestamp = (timestamp ?? DateTime.now()).roundDownToSeconds(),
3535
assets = assets ?? [],
36-
dependencies = dependencies ?? const Dependencies([]),
37-
metadata = metadata ?? const Metadata({});
36+
// ignore: prefer_const_constructors
37+
dependencies = dependencies ?? Dependencies([]),
38+
// ignore: prefer_const_constructors
39+
metadata = metadata ?? Metadata({});
3840

3941
static const _assetsKey = 'assets';
4042
static const _dependenciesKey = 'dependencies';

pkgs/native_assets_cli/lib/src/model/dependencies.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import '../utils/uri.dart';
1010
import '../utils/yaml.dart';
1111

1212
class Dependencies {
13+
/// The dependencies a build relied on.
1314
final List<Uri> dependencies;
1415

1516
const Dependencies(this.dependencies);
@@ -19,7 +20,8 @@ class Dependencies {
1920
if (yaml is YamlList) {
2021
return Dependencies.fromYaml(yaml);
2122
}
22-
return const Dependencies([]);
23+
// ignore: prefer_const_constructors
24+
return Dependencies([]);
2325
}
2426

2527
factory Dependencies.fromYaml(YamlList? yamlList) => Dependencies([

pkgs/native_assets_cli/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: native_assets_cli
22
description: >-
33
A library that contains the argument and file formats for implementing a
44
native assets CLI.
5-
version: 0.3.1
5+
version: 0.3.2
66
repository: https://github.com/dart-lang/native/tree/main/pkgs/native_assets_cli
77

88
topics:

pkgs/native_assets_cli/test/model/build_output_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,15 @@ version: ${BuildOutput.version}'''),
159159
throwsFormatException,
160160
);
161161
});
162+
163+
test('BuildOutput dependencies can be modified', () {
164+
// TODO(https://github.com/dart-lang/native/issues/25):
165+
// Remove once dependencies are made immutable.
166+
final buildOutput = BuildOutput();
167+
expect(
168+
() => buildOutput.dependencies.dependencies
169+
.add(Uri.file('path/to/file.ext')),
170+
returnsNormally,
171+
);
172+
});
162173
}

0 commit comments

Comments
 (0)