Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Add md file handling
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartmorgan committed May 6, 2022
1 parent 1e6e3e3 commit 0d42f3f
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
8 changes: 5 additions & 3 deletions script/tool/lib/src/common/package_state_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ PackageChangeState checkPackageChangeState(

if (!needsVersionChange &&
!isChangelog &&
// The example's main.dart is shown on pub.dev, but for anything else
// in the example publishing has no purpose.
!(components.contains('example') && components.last != 'main.dart') &&
// One of a few special files example will be shown on pub.dev, but for
// anything else in the example publishing has no purpose.
!(components.first == 'example' &&
!<String>{'main.dart', 'readme.md', 'example.md'}
.contains(components.last.toLowerCase())) &&
// Changes to tests don't need to be published.
!components.contains('test') &&
!components.contains('androidTest') &&
Expand Down
50 changes: 49 additions & 1 deletion script/tool/test/common/package_state_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void main() {
packagesDir = createPackagesDirectory(fileSystem: fileSystem);
});

group('pluginSupportsPlatform', () {
group('checkPackageChangeState', () {
test('reports version change needed for code changes', () async {
final RepositoryPackage package =
createFakePackage('a_package', packagesDir);
Expand Down Expand Up @@ -88,5 +88,53 @@ void main() {
expect(state.hasChanges, true);
expect(state.needsVersionChange, true);
});

test('requires a version change for example main', () async {
final RepositoryPackage package =
createFakePlugin('a_plugin', packagesDir);

const List<String> changedFiles = <String>[
'packages/a_plugin/example/lib/main.dart',
];

final PackageChangeState state = checkPackageChangeState(package,
changedPaths: changedFiles,
relativePackagePath: 'packages/a_plugin/');

expect(state.hasChanges, true);
expect(state.needsVersionChange, true);
});

test('requires a version change for example readme.md', () async {
final RepositoryPackage package =
createFakePlugin('a_plugin', packagesDir);

const List<String> changedFiles = <String>[
'packages/a_plugin/example/README.md',
];

final PackageChangeState state = checkPackageChangeState(package,
changedPaths: changedFiles,
relativePackagePath: 'packages/a_plugin/');

expect(state.hasChanges, true);
expect(state.needsVersionChange, true);
});

test('requires a version change for example example.md', () async {
final RepositoryPackage package =
createFakePlugin('a_plugin', packagesDir);

const List<String> changedFiles = <String>[
'packages/a_plugin/example/lib/example.md',
];

final PackageChangeState state = checkPackageChangeState(package,
changedPaths: changedFiles,
relativePackagePath: 'packages/a_plugin/');

expect(state.hasChanges, true);
expect(state.needsVersionChange, true);
});
});
}

0 comments on commit 0d42f3f

Please sign in to comment.