Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions script/tool/lib/src/publish_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ If running this command on CI, you can set the pub credential content in the $_p
''');
throw ToolExit(1);
}
credentialFile.createSync(recursive: true);
credentialFile.openSync(mode: FileMode.writeOnlyAppend)
..writeStringSync(credential)
..closeSync();
Expand Down
19 changes: 19 additions & 0 deletions script/tool/test/publish_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,25 @@ void main() {
]));
});

test('creates credential file from envirnoment variable if necessary',
() async {
createFakePlugin('foo', packagesDir, examples: <String>[]);
const String credentials = 'some credential';
platform.environment['PUB_CREDENTIALS'] = credentials;

await runCapturingPrint(commandRunner, <String>[
'publish',
'--packages=foo',
'--skip-confirmation',
'--pub-publish-flags',
'--server=bar'
]);

final File credentialFile = fileSystem.file(command.credentialsPath);
expect(credentialFile.existsSync(), true);
expect(credentialFile.readAsStringSync(), credentials);
});

test('throws if pub publish fails', () async {
createFakePlugin('foo', packagesDir, examples: <String>[]);

Expand Down