mirror of
https://github.com/subosito/flutter-action.git
synced 2024-08-16 10:19:50 +02:00
semver and channel for cache dir
This commit is contained in:
parent
aedc3a9f1e
commit
048d11febc
3 changed files with 17 additions and 6 deletions
|
@ -27,7 +27,12 @@ describe('installer tests', () => {
|
|||
|
||||
it('Downloads flutter', async () => {
|
||||
await installer.getFlutter('1.7.8+hotfix.4', 'stable');
|
||||
const sdkDir = path.join(toolDir, 'Flutter', '1.7.8', 'x64');
|
||||
const sdkDir = path.join(
|
||||
toolDir,
|
||||
'Flutter',
|
||||
'1.7.8-hotfix.4-stable',
|
||||
'x64'
|
||||
);
|
||||
|
||||
expect(fs.existsSync(`${sdkDir}.complete`)).toBe(true);
|
||||
expect(fs.existsSync(path.join(sdkDir, 'bin'))).toBe(true);
|
||||
|
@ -35,7 +40,7 @@ describe('installer tests', () => {
|
|||
|
||||
it('Downloads flutter from beta channel', async () => {
|
||||
await installer.getFlutter('1.8.3', 'beta');
|
||||
const sdkDir = path.join(toolDir, 'Flutter', '1.8.3', 'x64');
|
||||
const sdkDir = path.join(toolDir, 'Flutter', '1.8.3-beta', 'x64');
|
||||
|
||||
expect(fs.existsSync(`${sdkDir}.complete`)).toBe(true);
|
||||
expect(fs.existsSync(path.join(sdkDir, 'bin'))).toBe(true);
|
||||
|
|
|
@ -46,7 +46,10 @@ if (!tempDirectory) {
|
|||
}
|
||||
function getFlutter(version, channel) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let toolPath = tc.find('Flutter', version);
|
||||
// make semver compatible, eg: 1.7.8+hotfix.4 -> 1.7.8-hotfix.4
|
||||
const semver = version.replace('+', '-');
|
||||
const cleanver = `${semver}-${channel}`;
|
||||
let toolPath = tc.find('Flutter', cleanver);
|
||||
if (toolPath) {
|
||||
core.debug(`Tool found in cache ${toolPath}`);
|
||||
}
|
||||
|
@ -57,7 +60,7 @@ function getFlutter(version, channel) {
|
|||
let tempDir = generateTempDir();
|
||||
const sdkDir = yield extractDownload(sdkFile, tempDir);
|
||||
core.debug(`Flutter sdk extracted to ${sdkDir}`);
|
||||
toolPath = yield tc.cacheDir(sdkDir, 'Flutter', version);
|
||||
toolPath = yield tc.cacheDir(sdkDir, 'Flutter', cleanver);
|
||||
}
|
||||
core.exportVariable('FLUTTER_HOME', toolPath);
|
||||
core.addPath(path.join(toolPath, 'bin'));
|
||||
|
|
|
@ -32,7 +32,10 @@ export async function getFlutter(
|
|||
version: string,
|
||||
channel: string
|
||||
): Promise<void> {
|
||||
let toolPath = tc.find('Flutter', version);
|
||||
// make semver compatible, eg: 1.7.8+hotfix.4 -> 1.7.8-hotfix.4
|
||||
const semver = version.replace('+', '-');
|
||||
const cleanver = `${semver}-${channel}`;
|
||||
let toolPath = tc.find('Flutter', cleanver);
|
||||
|
||||
if (toolPath) {
|
||||
core.debug(`Tool found in cache ${toolPath}`);
|
||||
|
@ -46,7 +49,7 @@ export async function getFlutter(
|
|||
const sdkDir = await extractDownload(sdkFile, tempDir);
|
||||
core.debug(`Flutter sdk extracted to ${sdkDir}`);
|
||||
|
||||
toolPath = await tc.cacheDir(sdkDir, 'Flutter', version);
|
||||
toolPath = await tc.cacheDir(sdkDir, 'Flutter', cleanver);
|
||||
}
|
||||
|
||||
core.exportVariable('FLUTTER_HOME', toolPath);
|
||||
|
|
Loading…
Reference in a new issue