测试打印安装的go目录下所有文件
All checks were successful
Continuous Integration / GitHub Actions Test (push) Successful in 16s
All checks were successful
Continuous Integration / GitHub Actions Test (push) Successful in 16s
This commit is contained in:
parent
b2d397637e
commit
05a9860cd0
BIN
dist/index.js
generated
vendored
BIN
dist/index.js
generated
vendored
Binary file not shown.
BIN
dist/index.js.map
generated
vendored
BIN
dist/index.js.map
generated
vendored
Binary file not shown.
20
src/main.ts
20
src/main.ts
@ -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')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user