@@ -178,37 +178,46 @@ class Package {
178178
179179 final workspacePackages =
180180 pubspec.workspace.expand ((workspacePath) {
181- final Glob glob;
182- try {
183- glob = Glob (
184- pubspec.languageVersion.supportsWorkspaceGlobs
185- ? workspacePath
186- : Glob .quote (workspacePath),
187- );
188- } on FormatException catch (e) {
189- fail ('Failed to parse glob `$workspacePath `. $e ' );
190- }
191181 final packages = < Package > [];
192- for (final globResult in glob.listSync (root: dir)) {
193- final pubspecPath = p.join (globResult.path, 'pubspec.yaml' );
194- if (! fileExists (pubspecPath)) continue ;
195- packages.add (
196- Package .load (
197- globResult.path,
198- loadPubspec: loadPubspec,
199- withPubspecOverrides: withPubspecOverrides,
200- ),
201- );
202- }
203- if (packages.isEmpty) {
204- final globHint =
205- ! pubspec.languageVersion.supportsWorkspaceGlobs &&
206- _looksLikeGlob (workspacePath)
207- ? '''
182+ var globHint = '' ;
183+ if (pubspec.languageVersion.supportsWorkspaceGlobs) {
184+ final Glob glob;
185+ try {
186+ glob = Glob (workspacePath);
187+ } on FormatException catch (e) {
188+ fail ('Failed to parse glob `$workspacePath `. $e ' );
189+ }
190+ for (final globResult in glob.listSync (root: dir)) {
191+ final pubspecPath = p.join (globResult.path, 'pubspec.yaml' );
192+ if (! fileExists (pubspecPath)) continue ;
193+ packages.add (
194+ Package .load (
195+ globResult.path,
196+ loadPubspec: loadPubspec,
197+ withPubspecOverrides: withPubspecOverrides,
198+ ),
199+ );
200+ }
201+ } else {
202+ final pubspecPath = p.join (dir, workspacePath, 'pubspec.yaml' );
203+ if (! fileExists (pubspecPath)) {
204+ if (_looksLikeGlob (workspacePath)) {
205+ globHint = '''
208206\n\n Glob syntax is only supported from language version ${LanguageVersion .firstVersionWithWorkspaceGlobs }.
209207Consider changing the language version of ${p .join (dir , 'pubspec.yaml' )} to ${LanguageVersion .firstVersionWithWorkspaceGlobs }.
210- '''
211- : '' ;
208+ ''' ;
209+ }
210+ } else {
211+ packages.add (
212+ Package .load (
213+ p.join (dir, _useBackSlashesOnWindows (workspacePath)),
214+ loadPubspec: loadPubspec,
215+ withPubspecOverrides: withPubspecOverrides,
216+ ),
217+ );
218+ }
219+ }
220+ if (packages.isEmpty) {
212221 fail ('''
213222No workspace packages matching `$workspacePath `.
214223That was included in the workspace of `${p .join (dir , 'pubspec.yaml' )}`.$globHint
@@ -574,3 +583,9 @@ See https://dart.dev/go/workspaces-stray-files for details.
574583}
575584
576585bool _looksLikeGlob (String s) => Glob .quote (s) != s;
586+ String _useBackSlashesOnWindows (String path) {
587+ if (Platform .isWindows) {
588+ return p.joinAll (p.split (path));
589+ }
590+ return path;
591+ }
0 commit comments