Fix stray files check (#4464)
diff --git a/lib/src/entrypoint.dart b/lib/src/entrypoint.dart
index 7e7354e..cc2cbdf 100644
--- a/lib/src/entrypoint.dart
+++ b/lib/src/entrypoint.dart
@@ -1355,10 +1355,11 @@
break;
}
void deleteIfPresent(String path, String type) {
- fileExists(path);
- log.warning('Deleting old $type: `$path`.');
- deleteEntry(path);
- deletedAny = true;
+ if (fileExists(path)) {
+ log.warning('Deleting old $type: `$path`.');
+ deleteEntry(path);
+ deletedAny = true;
+ }
}
deleteIfPresent(p.join(dir, 'pubspec.lock'), 'lock-file');
diff --git a/test/workspace_test.dart b/test/workspace_test.dart
index ada3677..171ba7d 100644
--- a/test/workspace_test.dart
+++ b/test/workspace_test.dart
@@ -849,7 +849,7 @@
'myapp',
'1.2.3',
extras: {
- 'workspace': ['pkgs/a'],
+ 'workspace': ['pkgs/a', 'pkgs/b'],
},
sdk: '^3.5.0',
),
@@ -861,6 +861,12 @@
dir('test_data', []),
],
),
+ dir(
+ 'b',
+ [
+ libPubspec('b', '1.1.1', resolutionWorkspace: true),
+ ],
+ ),
]),
]).create();
// Directories outside the workspace should not be affected.
@@ -902,6 +908,7 @@
environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
warning: allOf(
contains('Deleting old lock-file: `.${s}pkgs/a${s}pubspec.lock'),
+ isNot(contains('.${s}pkgs/b${s}pubspec.lock')),
contains(
'Deleting old package config: '
'`.${s}pkgs/a$s.dart_tool${s}package_config.json`',