@@ -21,47 +21,27 @@ export 'package_config_types.dart';
21
21
22
22
/// Reads a specific package configuration file.
23
23
///
24
- /// The file must exist and be readable.
25
- /// It must be either a valid `package_config.json` file
26
- /// or a valid `.packages` file.
27
- /// It is considered a `package_config.json` file if its first character
28
- /// is a `{` .
29
- ///
30
- /// If the file is a `.packages` file (the file name is `.packages` )
31
- /// and [preferNewest] is true, the default, also checks if there is
32
- /// a `.dart_tool/package_config.json` file next
33
- /// to the original file, and if so, loads that instead.
34
- /// If [preferNewest] is set to false, a directly specified `.packages` file
35
- /// is loaded even if there is an available `package_config.json` file.
36
- /// The caller can determine this from the [PackageConfig.version]
37
- /// being 1 and look for a `package_config.json` file themselves.
24
+ /// The file must exist, be readable and be a valid `package_config.json` file.
38
25
///
39
26
/// If [onError] is provided, the configuration file parsing will report errors
40
27
/// by calling that function, and then try to recover.
41
28
/// The returned package configuration is a *best effort* attempt to create
42
29
/// a valid configuration from the invalid configuration file.
43
30
/// If no [onError] is provided, errors are thrown immediately.
44
31
Future <PackageConfig > loadPackageConfig (File file,
32
+ {void Function (Object error)? onError}) =>
33
+ readConfigFile (file, onError ?? throwError);
34
+
35
+ /// @nodoc
36
+ @Deprecated ('use loadPackageConfig instead' )
37
+ Future <PackageConfig > loadAnyPackageConfig (File file,
45
38
{bool preferNewest = true , void Function (Object error)? onError}) =>
46
- readAnyConfigFile (file, preferNewest, onError ?? throwError );
39
+ loadPackageConfig (file, onError: onError );
47
40
48
41
/// Reads a specific package configuration URI.
49
42
///
50
- /// The file of the URI must exist and be readable.
51
- /// It must be either a valid `package_config.json` file
52
- /// or a valid `.packages` file.
53
- /// It is considered a `package_config.json` file if its first
54
- /// non-whitespace character is a `{` .
55
- ///
56
- /// If [preferNewest] is true, the default, and the file is a `.packages` file,
57
- /// as determined by its file name being `.packages` ,
58
- /// first checks if there is a `.dart_tool/package_config.json` file
59
- /// next to the original file, and if so, loads that instead.
60
- /// The [file] *must not* be a `package:` URI.
61
- /// If [preferNewest] is set to false, a directly specified `.packages` file
62
- /// is loaded even if there is an available `package_config.json` file.
63
- /// The caller can determine this from the [PackageConfig.version]
64
- /// being 1 and look for a `package_config.json` file themselves.
43
+ /// The file of the URI must exist, be readable,
44
+ /// and be a valid `package_config.json` file.
65
45
///
66
46
/// If [loader] is provided, URIs are loaded using that function.
67
47
/// The future returned by the loader must complete with a [Uint8List]
@@ -88,15 +68,19 @@ Future<PackageConfig> loadPackageConfig(File file,
88
68
/// If no [onError] is provided, errors are thrown immediately.
89
69
Future <PackageConfig > loadPackageConfigUri (Uri file,
90
70
{Future <Uint8List ?> Function (Uri uri)? loader,
91
- bool preferNewest = true ,
92
71
void Function (Object error)? onError}) =>
93
- readAnyConfigFileUri (file, loader, onError ?? throwError, preferNewest);
72
+ readConfigFileUri (file, loader, onError ?? throwError);
73
+
74
+ /// @nodoc
75
+ @Deprecated ('use loadPackageConfigUri instead' )
76
+ Future <PackageConfig > loadAnyPackageConfigUri (Uri uri,
77
+ {bool preferNewest = true , void Function (Object error)? onError}) =>
78
+ loadPackageConfigUri (uri, onError: onError);
94
79
95
80
/// Finds a package configuration relative to [directory] .
96
81
///
97
- /// If [directory] contains a package configuration,
98
- /// either a `.dart_tool/package_config.json` file or,
99
- /// if not, a `.packages` , then that file is loaded.
82
+ /// If [directory] contains a `.dart_tool/package_config.json` file,
83
+ /// then that file is loaded.
100
84
///
101
85
/// If no file is found in the current directory,
102
86
/// then the parent directories are checked recursively,
@@ -129,9 +113,8 @@ Future<PackageConfig?> findPackageConfig(Directory directory,
129
113
130
114
/// Finds a package configuration relative to [location] .
131
115
///
132
- /// If [location] contains a package configuration,
133
- /// either a `.dart_tool/package_config.json` file or,
134
- /// if not, a `.packages` , then that file is loaded.
116
+ /// If [location] contains a `.dart_tool/package_config.json`
117
+ /// package configuration file or, then that file is loaded.
135
118
/// The [location] URI *must not* be a `package:` URI.
136
119
/// It should be a hierarchical URI which is supported
137
120
/// by [loader] .
@@ -189,9 +172,6 @@ Future<PackageConfig?> findPackageConfigUri(Uri location,
189
172
/// If the `.dart_tool/` directory does not exist, it is created.
190
173
/// If it cannot be created, this operation fails.
191
174
///
192
- /// Also writes a `.packages` file in [directory] .
193
- /// This will stop happening eventually as the `.packages` file becomes
194
- /// discontinued.
195
175
/// A comment is generated if `[PackageConfig.extraData]` contains a
196
176
/// `"generator"` entry.
197
177
Future <void > savePackageConfig (
0 commit comments