@@ -121,6 +121,8 @@ class PublishPluginCommand extends PackageLoopingCommand {
121121 List <String > _existingGitTags = < String > [];
122122 // The remote to push tags to.
123123 late _RemoteInfo _remote;
124+ // Flags to pass to `pub publish`.
125+ late List <String > _publishFlags;
124126
125127 @override
126128 String get successSummaryMessage => 'published' ;
@@ -149,6 +151,11 @@ class PublishPluginCommand extends PackageLoopingCommand {
149151 _existingGitTags = (existingTagsResult.stdout as String ).split ('\n ' )
150152 ..removeWhere ((String element) => element.isEmpty);
151153
154+ _publishFlags = < String > [
155+ ...getStringListArg (_pubFlagsOption),
156+ if (getBoolArg (_skipConfirmationFlag)) '--force' ,
157+ ];
158+
152159 if (getBoolArg (_dryRunFlag)) {
153160 print ('=============== DRY RUN ===============' );
154161 }
@@ -333,22 +340,18 @@ Safe to ignore if the package is deleted in this commit.
333340
334341 Future <bool > _publish (RepositoryPackage package) async {
335342 print ('Publishing...' );
336- final List <String > publishFlags = getStringListArg (_pubFlagsOption);
337- print ('Running `pub publish ${publishFlags .join (' ' )}` in '
343+ print ('Running `pub publish ${_publishFlags .join (' ' )}` in '
338344 '${package .directory .absolute .path }...\n ' );
339345 if (getBoolArg (_dryRunFlag)) {
340346 return true ;
341347 }
342348
343- if (getBoolArg (_skipConfirmationFlag)) {
344- publishFlags.add ('--force' );
345- }
346- if (publishFlags.contains ('--force' )) {
349+ if (_publishFlags.contains ('--force' )) {
347350 _ensureValidPubCredential ();
348351 }
349352
350353 final io.Process publish = await processRunner.start (
351- flutterCommand, < String > ['pub' , 'publish' ] + publishFlags ,
354+ flutterCommand, < String > ['pub' , 'publish' , ..._publishFlags] ,
352355 workingDirectory: package.directory);
353356 publish.stdout.transform (utf8.decoder).listen ((String data) => print (data));
354357 publish.stderr.transform (utf8.decoder).listen ((String data) => print (data));
0 commit comments