Skip to content

Commit

Permalink
Do not detect workspaces as dart packages
Browse files Browse the repository at this point in the history
  • Loading branch information
passsy committed Jul 16, 2024
1 parent c9c2f16 commit 939cb5c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sidekick_core/lib/src/dart_package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ class DartPackage {
return null;
}

final workspaceFile = pubspec['workspace'];
if (workspaceFile != null) {
// Workspace files are not packages
// flutter.dev/go/pub-workspace
return null;
}

// Check for (optional) flutter dependency
final deps = pubspec['dependencies'] as YamlMap?;
final withFlutter = deps?.containsKey('flutter') ?? false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,24 @@ flutter:
expect(package!.name, 'package_name');
expect(package.isFlutterPackage, isTrue);
});

test('a workspace is not a DartPackage', () {
final tempDir = Directory.systemTemp.createTempSync();
addTearDown(() => tempDir.deleteSync(recursive: true));
tempDir.file('pubspec.yaml')
..createSync()
..writeAsStringSync('''
name: _ # Can be anything, _ by convention.
environment:
sdk: ^3.5.0 # Must be ^3.5.0 or later for workspace to be allowed
workspace:
- pkgs/app1 # The workspace-packages must be subdirectories
- pkgs/app2
- pkgs/shared
''');

final package = DartPackage.fromDirectory(tempDir);
expect(package, isNull);
});
});
}

0 comments on commit 939cb5c

Please sign in to comment.