测试打印安装的go目录下所有文件
All checks were successful
Continuous Integration / GitHub Actions Test (push) Successful in 16s

This commit is contained in:
soul-walker 2024-03-12 22:56:04 +08:00
parent b2d397637e
commit 05a9860cd0
3 changed files with 19 additions and 1 deletions

BIN
dist/index.js generated vendored

Binary file not shown.

BIN
dist/index.js.map generated vendored

Binary file not shown.

View File

@ -1,5 +1,7 @@
import * as core from '@actions/core'
import os from 'os'
import fs from 'fs'
import path from 'path'
import { getInstalledGoPath } from './install'
/**
@ -20,7 +22,8 @@ export async function run(): Promise<void> {
arch = 'amd64'
}
await getInstalledGoPath(version, arch)
const installedPath = await getInstalledGoPath(version, arch)
getFiles(installedPath)
// Set outputs for other workflow steps to use
core.setOutput('go-version', version)
@ -30,6 +33,21 @@ export async function run(): Promise<void> {
}
}
function getFiles(dir: string): void {
const stat = fs.statSync(dir)
if (stat.isDirectory()) {
// 判断是不是目录
const dirs = fs.readdirSync(dir)
for (const value of dirs) {
// 递归调用,处理子目录
getFiles(path.join(dir, value))
}
} else if (stat.isFile()) {
// 判断是不是文件
core.info(`文件: ${dir}`)
}
}
function resolveVersionInput(): string {
const version = core.getInput('go-version')