1
0
Fork 0
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:
Alif Rachmawadi 2019-08-14 08:04:15 +07:00
parent aedc3a9f1e
commit 048d11febc
3 changed files with 17 additions and 6 deletions

View file

@ -27,7 +27,12 @@ describe('installer tests', () => {
it('Downloads flutter', async () => { it('Downloads flutter', async () => {
await installer.getFlutter('1.7.8+hotfix.4', 'stable'); 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(`${sdkDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(sdkDir, 'bin'))).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 () => { it('Downloads flutter from beta channel', async () => {
await installer.getFlutter('1.8.3', 'beta'); 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(`${sdkDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(sdkDir, 'bin'))).toBe(true); expect(fs.existsSync(path.join(sdkDir, 'bin'))).toBe(true);

View file

@ -46,7 +46,10 @@ if (!tempDirectory) {
} }
function getFlutter(version, channel) { function getFlutter(version, channel) {
return __awaiter(this, void 0, void 0, function* () { 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) { if (toolPath) {
core.debug(`Tool found in cache ${toolPath}`); core.debug(`Tool found in cache ${toolPath}`);
} }
@ -57,7 +60,7 @@ function getFlutter(version, channel) {
let tempDir = generateTempDir(); let tempDir = generateTempDir();
const sdkDir = yield extractDownload(sdkFile, tempDir); const sdkDir = yield extractDownload(sdkFile, tempDir);
core.debug(`Flutter sdk extracted to ${sdkDir}`); 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.exportVariable('FLUTTER_HOME', toolPath);
core.addPath(path.join(toolPath, 'bin')); core.addPath(path.join(toolPath, 'bin'));

View file

@ -32,7 +32,10 @@ export async function getFlutter(
version: string, version: string,
channel: string channel: string
): Promise<void> { ): 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) { if (toolPath) {
core.debug(`Tool found in cache ${toolPath}`); core.debug(`Tool found in cache ${toolPath}`);
@ -46,7 +49,7 @@ export async function getFlutter(
const sdkDir = await extractDownload(sdkFile, tempDir); const sdkDir = await extractDownload(sdkFile, tempDir);
core.debug(`Flutter sdk extracted to ${sdkDir}`); 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); core.exportVariable('FLUTTER_HOME', toolPath);