修改下载文件arch问题
All checks were successful
Continuous Integration / GitHub Actions Test (push) Successful in 29s

This commit is contained in:
soul-walker 2024-03-20 20:42:12 +08:00
parent 974228f061
commit f586867fa1
4 changed files with 8 additions and 36 deletions

View File

@ -1,25 +0,0 @@
/**
* Unit tests for src/wait.ts
*/
import { wait } from '../src/wait'
import { expect } from '@jest/globals'
describe('wait.ts', () => {
it('throws an invalid number', async () => {
const input = parseInt('foo', 10)
expect(isNaN(input)).toBe(true)
await expect(wait(input)).rejects.toThrow('milliseconds not a number')
})
it('waits with a valid number', async () => {
const start = new Date()
await wait(500)
const end = new Date()
const delta = Math.abs(end.getTime() - start.getTime())
expect(delta).toBeGreaterThan(450)
})
})

BIN
dist/index.js generated vendored

Binary file not shown.

View File

@ -5,7 +5,8 @@ import os from 'os'
const BinBaseUrl = 'https://nodejs.org/dist/' const BinBaseUrl = 'https://nodejs.org/dist/'
const DestDir = '/denv' const DestDir = '/denv'
export function getFileName(version: string, arch = os.arch()): string { export function getFileName(version: string): string {
const arch = 'x64'
return `node-${version}-${os.platform()}-${arch}.tar.gz` return `node-${version}-${os.platform()}-${arch}.tar.gz`
} }

View File

@ -1,7 +1,6 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import * as io from '@actions/io' import * as io from '@actions/io'
import * as ac from '@actions/cache' import * as ac from '@actions/cache'
import os from 'os'
import path from 'path' import path from 'path'
import cp from 'child_process' import cp from 'child_process'
import { getFileName, getRootPath, getInstalledPath } from './install' import { getFileName, getRootPath, getInstalledPath } from './install'
@ -18,16 +17,13 @@ export async function run(): Promise<void> {
const version: string = resolveVersionInput() const version: string = resolveVersionInput()
// Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true // Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true
core.debug(`The input version is: ${version}`) core.debug(`The input version is: ${version}`)
// 获取输入的architecture // // 获取输入的architecture
let arch = core.getInput('architecture') // let arch = core.getInput('architecture')
if (!arch) { // if (!arch) {
arch = os.arch() // arch = os.arch()
} // }
if (arch === 'x64') {
arch = 'amd64'
}
// 构建文件名 // 构建文件名
const dlgfName = getFileName(version, arch) const dlgfName = getFileName(version)
let installedPath = getRootPath(version) let installedPath = getRootPath(version)
// 尝试从缓存中恢复 // 尝试从缓存中恢复
const rcr = await ac.restoreCache([installedPath], dlgfName) const rcr = await ac.restoreCache([installedPath], dlgfName)