From 8727c85ea481d2cc63f60ed7b91049c41f6b0578 Mon Sep 17 00:00:00 2001 From: Sigurd Meldgaard Date: Tue, 10 Dec 2024 10:29:35 +0100 Subject: [PATCH] Fix stray files check (#4464) --- lib/src/entrypoint.dart | 9 +++++---- test/workspace_test.dart | 9 ++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/src/entrypoint.dart b/lib/src/entrypoint.dart index 7e7354e66..cc2cbdfb0 100644 --- a/lib/src/entrypoint.dart +++ b/lib/src/entrypoint.dart @@ -1355,10 +1355,11 @@ See https://dart.dev/go/sdk-constraint 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 ada3677b1..171ba7d07 100644 --- a/test/workspace_test.dart +++ b/test/workspace_test.dart @@ -849,7 +849,7 @@ foo:foomain''', 'myapp', '1.2.3', extras: { - 'workspace': ['pkgs/a'], + 'workspace': ['pkgs/a', 'pkgs/b'], }, sdk: '^3.5.0', ), @@ -861,6 +861,12 @@ foo:foomain''', 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 @@ foo:foomain''', 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`',