Skip to content

Commit cf9f46c

Browse files
authored
fix(packages_get): recursive installation ignored directories fixes (#283)
1 parent f1d14c8 commit cf9f46c

File tree

2 files changed

+61
-4
lines changed

2 files changed

+61
-4
lines changed

lib/src/cli/cli.dart

+13-4
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,21 @@ class _Cmd {
5555
}
5656
}
5757

58-
final _ignoredDirectories = RegExp(
59-
'ios|android|windows|linux|macos|.symlinks|.plugin_symlinks|.dart_tool|build',
60-
);
58+
const _ignoredDirectories = {
59+
'ios',
60+
'android',
61+
'windows',
62+
'linux',
63+
'macos',
64+
'.symlinks',
65+
'.plugin_symlinks',
66+
'.dart_tool',
67+
'build',
68+
};
6169

6270
bool _isPubspec(FileSystemEntity entity) {
63-
if (entity.path.contains(_ignoredDirectories)) return false;
71+
final segments = p.split(entity.path).toSet();
72+
if (segments.intersection(_ignoredDirectories).isNotEmpty) return false;
6473
if (entity is! File) return false;
6574
return p.basename(entity.path) == 'pubspec.yaml';
6675
}

test/src/commands/packages_test.dart

+48
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,54 @@ void main() {
232232
);
233233
}).called(2);
234234
});
235+
236+
test(
237+
'completes normally '
238+
'when pubspec.yaml exists and directory is not ignored (recursive)',
239+
() async {
240+
final tempDirectory = Directory.systemTemp.createTempSync();
241+
final directory = Directory(
242+
path.join(tempDirectory.path, 'macos_plugin'),
243+
);
244+
final pubspecA = File(
245+
path.join(directory.path, 'example_a', 'pubspec.yaml'),
246+
);
247+
final pubspecB = File(
248+
path.join(directory.path, 'example_b', 'pubspec.yaml'),
249+
);
250+
pubspecA
251+
..createSync(recursive: true)
252+
..writeAsStringSync(
253+
'''
254+
name: example_a
255+
version: 0.1.0
256+
257+
environment:
258+
sdk: ">=2.12.0 <3.0.0"
259+
''',
260+
);
261+
pubspecB
262+
..createSync(recursive: true)
263+
..writeAsStringSync(
264+
'''
265+
name: example_b
266+
version: 0.1.0
267+
268+
environment:
269+
sdk: ">=2.12.0 <3.0.0"
270+
''',
271+
);
272+
273+
final result = await commandRunner.run(
274+
['packages', 'get', '--recursive', directory.path],
275+
);
276+
expect(result, equals(ExitCode.success.code));
277+
verify(() {
278+
logger.progress(
279+
any(that: contains('Running "flutter packages get" in')),
280+
);
281+
}).called(2);
282+
});
235283
});
236284
});
237285
}

0 commit comments

Comments
 (0)