1
0
Fork 0
mirror of https://github.com/subosito/flutter-action.git synced 2024-08-16 10:19:50 +02:00

Export PUB_CACHE if it is not in env

Export `PUB_CACHE` if it is not configured before calling the action.
This ensures that flutter and dart use the same cache.
It also enables other tools to use this official Dart env variable.
This commit is contained in:
Peter Leibiger 2021-04-28 20:25:09 +02:00
parent 13141e86c3
commit 8f6ad7c383
No known key found for this signature in database
GPG key ID: 855A3ADD4CC39135
2 changed files with 15 additions and 2 deletions

7
dist/index.js vendored
View file

@ -123,9 +123,14 @@ function getFlutter(version, channel) {
toolPath = yield tc.cacheDir(sdkDir, 'flutter', cleanver);
}
core.exportVariable('FLUTTER_ROOT', toolPath);
let pubCachePath = process.env['PUB_CACHE'] || '';
if (!pubCachePath) {
pubCachePath = path.join(toolPath, '.pub-cache');
core.exportVariable('PUB_CACHE', pubCachePath);
}
core.addPath(path.join(toolPath, 'bin'));
core.addPath(path.join(toolPath, 'bin', 'cache', 'dart-sdk', 'bin'));
core.addPath(path.join(toolPath, '.pub-cache', 'bin'));
core.addPath(path.join(pubCachePath, 'bin'));
if (useMaster) {
yield exec.exec('flutter', ['channel', 'master']);
yield exec.exec('flutter', ['upgrade']);

View file

@ -46,9 +46,17 @@ export async function getFlutter(
}
core.exportVariable('FLUTTER_ROOT', toolPath);
let pubCachePath = process.env['PUB_CACHE'] || '';
if (!pubCachePath) {
pubCachePath = path.join(toolPath, '.pub-cache');
core.exportVariable('PUB_CACHE', pubCachePath);
}
core.addPath(path.join(toolPath, 'bin'));
core.addPath(path.join(toolPath, 'bin', 'cache', 'dart-sdk', 'bin'));
core.addPath(path.join(toolPath, '.pub-cache', 'bin'));
core.addPath(path.join(pubCachePath, 'bin'));
if (useMaster) {
await exec.exec('flutter', ['channel', 'master']);