Skip to content

Commit ce909e4

Browse files
authored
Use the correct pub credential location for deploying sub-packages (#1997)
1 parent eea0717 commit ce909e4

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ dev_dependencies:
5353
test_descriptor: ^2.0.0
5454
test_process: ^2.0.0
5555
yaml: ^3.1.0
56+
cli_util: ^0.4.0

tool/grind/subpackages.dart

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'dart:io';
66
import 'dart:convert';
77

88
import 'package:cli_pkg/cli_pkg.dart' as pkg;
9+
import 'package:cli_util/cli_util.dart';
910
import 'package:grinder/grinder.dart';
1011
import 'package:http/http.dart' as http;
1112
import 'package:path/path.dart' as p;
@@ -15,22 +16,8 @@ import 'package:yaml/yaml.dart';
1516
import 'utils.dart';
1617

1718
/// The path in which pub expects to find its credentials file.
18-
final String _pubCredentialsPath = () {
19-
// This follows the same logic as pub:
20-
// https://github.com/dart-lang/pub/blob/d99b0d58f4059d7bb4ac4616fd3d54ec00a2b5d4/lib/src/system_cache.dart#L34-L43
21-
String cacheDir;
22-
var pubCache = Platform.environment['PUB_CACHE'];
23-
if (pubCache != null) {
24-
cacheDir = pubCache;
25-
} else if (Platform.isWindows) {
26-
var appData = Platform.environment['APPDATA']!;
27-
cacheDir = p.join(appData, 'Pub', 'Cache');
28-
} else {
29-
cacheDir = p.join(Platform.environment['HOME']!, '.pub-cache');
30-
}
31-
32-
return p.join(cacheDir, 'credentials.json');
33-
}();
19+
final String _pubCredentialsPath =
20+
p.join(applicationConfigHome('dart'), 'pub-credentials.json');
3421

3522
@Task('Deploy sub-packages to pub.')
3623
Future<void> deploySubPackages() async {

0 commit comments

Comments
 (0)