mirror of https://github.com/aminya/setup-cpp
fix: use dayjs to format time
This commit is contained in:
parent
98c3fd0382
commit
6c260e10fa
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -37,12 +37,12 @@
|
|||
"@actions/exec": "^1.1.1",
|
||||
"@actions/io": "^1.1.2",
|
||||
"@actions/tool-cache": "^1.7.2",
|
||||
"dayjs": "^1.11.1",
|
||||
"execa": "^5.1.1",
|
||||
"mri": "^1.2.0",
|
||||
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
|
||||
"semver": "7.3.7",
|
||||
"setup-python": "github:actions/setup-python#7f80679172b057fc5e90d70d197929d454754a5a",
|
||||
"time-delta": "^1.0.0",
|
||||
"untildify": "^4.0.0",
|
||||
"which": "^2.0.2"
|
||||
},
|
||||
|
|
|
@ -22,6 +22,7 @@ specifiers:
|
|||
cross-env: 7.0.3
|
||||
cross-spawn: ^7.0.3
|
||||
cspell: ^5.19.7
|
||||
dayjs: ^1.11.1
|
||||
eslint: ^8.13.0
|
||||
eslint-config-atomic: ^1.17.1
|
||||
execa: ^5.1.1
|
||||
|
@ -48,6 +49,7 @@ dependencies:
|
|||
'@actions/exec': 1.1.1
|
||||
'@actions/io': 1.1.2
|
||||
'@actions/tool-cache': 1.7.2
|
||||
dayjs: 1.11.1
|
||||
execa: 5.1.1
|
||||
mri: 1.2.0
|
||||
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
|
||||
|
@ -3253,6 +3255,10 @@ packages:
|
|||
resolution: {integrity: sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=}
|
||||
dev: true
|
||||
|
||||
/dayjs/1.11.1:
|
||||
resolution: {integrity: sha512-ER7EjqVAMkRRsxNCC5YqJ9d9VQYuWdGt7aiH2qA5R5wt8ZmWaP2dLUSIK6y/kVzLMlmh1Tvu5xUf4M/wdGJ5KA==}
|
||||
dev: false
|
||||
|
||||
/debug/2.6.9:
|
||||
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
|
||||
dependencies:
|
||||
|
|
30
src/main.ts
30
src/main.ts
|
@ -18,10 +18,9 @@ import { setupPython } from "./python/python"
|
|||
import mri from "mri"
|
||||
import { untildify_user as untildify } from "./utils/path/untildify"
|
||||
import { isGitHubCI } from "./utils/env/isci"
|
||||
import * as timeDelta from "time-delta"
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
import enLocale from "time-delta/locales/en"
|
||||
import dayjs from "dayjs"
|
||||
// eslint-disable-next-line import/no-unassigned-import
|
||||
import "dayjs/locale/en"
|
||||
|
||||
import semverValid from "semver/functions/valid"
|
||||
import { getVersion } from "./default_versions"
|
||||
|
@ -128,10 +127,9 @@ export async function main(args: string[]): Promise<number> {
|
|||
const successMessages: string[] = []
|
||||
const errorMessages: string[] = []
|
||||
|
||||
const timeFormatter = timeDelta.create()
|
||||
timeDelta.addLocale(enLocale as timeDelta.LocaleData)
|
||||
let time1: Date
|
||||
let time2: Date
|
||||
dayjs.locale("en")
|
||||
let time1: number
|
||||
let time2: number
|
||||
|
||||
// installing the specified tools
|
||||
|
||||
|
@ -143,7 +141,7 @@ export async function main(args: string[]): Promise<number> {
|
|||
// skip if undefined
|
||||
if (version !== undefined) {
|
||||
// running the setup function for this tool
|
||||
time1 = new Date(Date.now())
|
||||
time1 = Date.now()
|
||||
startGroup(`Installing ${tool} ${version}`)
|
||||
try {
|
||||
let installationInfo: InstallationInfo | undefined | void
|
||||
|
@ -165,14 +163,14 @@ export async function main(args: string[]): Promise<number> {
|
|||
errorMessages.push(`${tool} failed to install`)
|
||||
}
|
||||
endGroup()
|
||||
time2 = new Date(Date.now())
|
||||
info(`took ${timeFormatter.format(time1, time2) as string}`)
|
||||
time2 = Date.now()
|
||||
info(`took ${dayjs(new Date(time2 - time1)).format()}`)
|
||||
}
|
||||
}
|
||||
|
||||
// installing the specified compiler
|
||||
const maybeCompiler = opts.compiler
|
||||
time1 = new Date(Date.now())
|
||||
time1 = Date.now()
|
||||
try {
|
||||
if (maybeCompiler !== undefined) {
|
||||
const { compiler, version } = getCompilerInfo(maybeCompiler)
|
||||
|
@ -219,15 +217,15 @@ export async function main(args: string[]): Promise<number> {
|
|||
}
|
||||
}
|
||||
endGroup()
|
||||
time2 = new Date(Date.now())
|
||||
info(`took ${timeFormatter.format(time1, time2) as string}`)
|
||||
time2 = Date.now()
|
||||
info(`took ${dayjs(new Date(time2 - time1)).format()}`)
|
||||
}
|
||||
} catch (e) {
|
||||
error(e as string | Error)
|
||||
errorMessages.push(`Failed to install the ${maybeCompiler}`)
|
||||
endGroup()
|
||||
time2 = new Date(Date.now())
|
||||
info(`took ${timeFormatter.format(time1, time2) as string}`)
|
||||
time2 = Date.now()
|
||||
info(`took ${dayjs(new Date(time2 - time1)).format()}`)
|
||||
}
|
||||
|
||||
if (successMessages.length === 0 && errorMessages.length === 0) {
|
||||
|
|
Loading…
Reference in New Issue