Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add flag to allow pre-release
  • Loading branch information
Chris Yang committed Apr 23, 2021
commit db8fb5d5289b6921380d5fe21d60a6de7b862208
16 changes: 15 additions & 1 deletion script/tool/lib/src/publish_check_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ class PublishCheckCommand extends PluginCommand {
Directory packagesDir,
FileSystem fileSystem, {
ProcessRunner processRunner = const ProcessRunner(),
}) : super(packagesDir, fileSystem, processRunner: processRunner);
}) : super(packagesDir, fileSystem, processRunner: processRunner) {
argParser.addFlag(
_allowPrereleaseFlag,
help: 'Allows the pre-release SDK warning to pass.'
'When enabled, a pub warning, which asks to publish the package as a pre-release version when'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing spaces at the ends of these string literals, so they won't concatenate correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new line after the first sentence.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second part still has the same problem; this will print "[...] a pre-release verison whenthe SDK [...]"

'the SDK constraint is a pre-release version, is ignored.',
defaultsTo: false,
);
}

static const String _allowPrereleaseFlag = 'allow-pre-release';

@override
final String name = 'publish-check';
Expand Down Expand Up @@ -98,6 +108,10 @@ class PublishCheckCommand extends PluginCommand {
return true;
}

if (!(argResults[_allowPrereleaseFlag] as bool)) {
return false;
}

await stdOutCompleter.future;
await stdInCompleter.future;

Expand Down
5 changes: 3 additions & 2 deletions script/tool/test/publish_check_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void main() {
throwsA(isA<ToolExit>()));
});

test('fail on prerelease', () async {
test('pass on prerelease is --allow-pre-release flag is on', () async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: s/is/if/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

createFakePlugin('d');

const String preReleaseOutput = 'Package has 1 warning.'
Expand All @@ -105,7 +105,8 @@ void main() {

processRunner.processesToReturn.add(process);

expect(runner.run(<String>['publish-check']), throwsA(isA<ToolExit>()));
expect(runner.run(<String>['publish-check', '--allow-pre-release']),
completes);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need a new test that the same setup fails without --allow-pre-release

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

});
}
Expand Down