Skip to content

Commit

Permalink
fix extract method
Browse files Browse the repository at this point in the history
  • Loading branch information
utamori committed Aug 22, 2023
1 parent 9207d40 commit 68f84c8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
4 changes: 1 addition & 3 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

import { test } from '@jest/globals'

import {test} from '@jest/globals'

// shows how the runner will run a javascript action with env / stdout protocol
test('test runs', () => {
Expand Down
14 changes: 10 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

32 changes: 18 additions & 14 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
import { getInput, exportVariable } from '@actions/core'
import { readFileSync } from "node:fs";
import {getInput, exportVariable} from '@actions/core'
import {readFileSync} from 'node:fs'

async function run(): Promise<void> {
const path = getInput('path')

const path = getInput('path');

const content = readFileSync(path, { encoding: 'utf8' });

const content = readFileSync(path, {encoding: 'utf8'})

for (const line of content.split('\n')) {
if (line.trim() === '') continue;
if (line.trim() === '') continue

const [name, versionStatus] = line.split(' ');
const [name, versionStatus] = line.split(' ')

if (name === 'flutter') {
const [version, channel] = versionStatus.split('-');
exportVariable('FLUTTER_VERSION', version)
exportVariable('FLUTTER_CHANNEL', channel)
break;
if (versionStatus.includes('-stable')) {
exportVariable('FLUTTER_VERSION', versionStatus.replace(/-stable$/, ''))
exportVariable('FLUTTER_CHANNEL', 'stable')
break
} else if (versionStatus.includes('.pre-beta')) {
exportVariable(
'FLUTTER_VERSION',
versionStatus.replace(/\.pre-beta$/, '')
)
exportVariable('FLUTTER_CHANNEL', 'beta')
break
}
}

}

}

run()

0 comments on commit 68f84c8

Please sign in to comment.