Skip to content

Commit

Permalink
fix(packages_get): recursive installation ignored directories fixes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel committed Feb 14, 2022
1 parent f1d14c8 commit cf9f46c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/src/cli/cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,21 @@ class _Cmd {
}
}

final _ignoredDirectories = RegExp(
'ios|android|windows|linux|macos|.symlinks|.plugin_symlinks|.dart_tool|build',
);
const _ignoredDirectories = {
'ios',
'android',
'windows',
'linux',
'macos',
'.symlinks',
'.plugin_symlinks',
'.dart_tool',
'build',
};

bool _isPubspec(FileSystemEntity entity) {
if (entity.path.contains(_ignoredDirectories)) return false;
final segments = p.split(entity.path).toSet();
if (segments.intersection(_ignoredDirectories).isNotEmpty) return false;
if (entity is! File) return false;
return p.basename(entity.path) == 'pubspec.yaml';
}
48 changes: 48 additions & 0 deletions test/src/commands/packages_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,54 @@ void main() {
);
}).called(2);
});

test(
'completes normally '
'when pubspec.yaml exists and directory is not ignored (recursive)',
() async {
final tempDirectory = Directory.systemTemp.createTempSync();
final directory = Directory(
path.join(tempDirectory.path, 'macos_plugin'),
);
final pubspecA = File(
path.join(directory.path, 'example_a', 'pubspec.yaml'),
);
final pubspecB = File(
path.join(directory.path, 'example_b', 'pubspec.yaml'),
);
pubspecA
..createSync(recursive: true)
..writeAsStringSync(
'''
name: example_a
version: 0.1.0
environment:
sdk: ">=2.12.0 <3.0.0"
''',
);
pubspecB
..createSync(recursive: true)
..writeAsStringSync(
'''
name: example_b
version: 0.1.0
environment:
sdk: ">=2.12.0 <3.0.0"
''',
);

final result = await commandRunner.run(
['packages', 'get', '--recursive', directory.path],
);
expect(result, equals(ExitCode.success.code));
verify(() {
logger.progress(
any(that: contains('Running "flutter packages get" in')),
);
}).called(2);
});
});
});
}

0 comments on commit cf9f46c

Please sign in to comment.