Use the correct pub credential location for deploying sub-packages (#1997)

This commit is contained in:
Natalie Weizenbaum 2023-06-07 17:58:46 -07:00 committed by GitHub
parent eea0717ad3
commit ce909e454d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 16 deletions

View File

@ -53,3 +53,4 @@ dev_dependencies:
test_descriptor: ^2.0.0
test_process: ^2.0.0
yaml: ^3.1.0
cli_util: ^0.4.0

View File

@ -6,6 +6,7 @@ import 'dart:io';
import 'dart:convert';
import 'package:cli_pkg/cli_pkg.dart' as pkg;
import 'package:cli_util/cli_util.dart';
import 'package:grinder/grinder.dart';
import 'package:http/http.dart' as http;
import 'package:path/path.dart' as p;
@ -15,22 +16,8 @@ import 'package:yaml/yaml.dart';
import 'utils.dart';
/// The path in which pub expects to find its credentials file.
final String _pubCredentialsPath = () {
// This follows the same logic as pub:
// https://github.com/dart-lang/pub/blob/d99b0d58f4059d7bb4ac4616fd3d54ec00a2b5d4/lib/src/system_cache.dart#L34-L43
String cacheDir;
var pubCache = Platform.environment['PUB_CACHE'];
if (pubCache != null) {
cacheDir = pubCache;
} else if (Platform.isWindows) {
var appData = Platform.environment['APPDATA']!;
cacheDir = p.join(appData, 'Pub', 'Cache');
} else {
cacheDir = p.join(Platform.environment['HOME']!, '.pub-cache');
}
return p.join(cacheDir, 'credentials.json');
}();
final String _pubCredentialsPath =
p.join(applicationConfigHome('dart'), 'pub-credentials.json');
@Task('Deploy sub-packages to pub.')
Future<void> deploySubPackages() async {