mirror of
https://github.com/flutter/packages.git
synced 2025-08-06 08:53:11 +08:00
[tool] Ensure that publish credential path is available (#3970)
When writing pub credentials, ensure that the target paths exists before trying to write the file. In the past this would have worked because the credentials were in the pub cache, and the pub cache would exist by the time the repo tooling code was running. The new location, however, is a configuration directory that is unlikely to exist before anything involving `pub` credentials has run. Should fix the latest `release` failure: https://github.com/flutter/packages/actions/runs/4949005383/jobs/8854219784
This commit is contained in:
@ -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>[]);
|
||||
|
||||
|
Reference in New Issue
Block a user