fix: use time-delta fork to format time

This commit is contained in:
Amin Yahyaabadi 2022-04-18 05:07:02 -07:00
parent 4b165e7747
commit 20592b193c
5 changed files with 27 additions and 25 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -42,7 +42,7 @@
"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",
"time-delta": "github:aminya/time-delta#a6f84237aa249d246488d06439acbe0e6e364fd5",
"untildify": "^4.0.0",
"which": "^2.0.2"
},

View File

@ -37,7 +37,7 @@ specifiers:
setup-python: github:actions/setup-python#7f80679172b057fc5e90d70d197929d454754a5a
shx: 0.3.4
terser-config-atomic: ^0.1.1
time-delta: ^1.0.0
time-delta: github:aminya/time-delta#a6f84237aa249d246488d06439acbe0e6e364fd5
ts-jest: ^27.1.4
typescript: ^4.6.3
untildify: ^4.0.0
@ -53,7 +53,7 @@ dependencies:
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
semver: 7.3.7
setup-python: github.com/actions/setup-python/7f80679172b057fc5e90d70d197929d454754a5a
time-delta: 1.0.0
time-delta: github.com/aminya/time-delta/a6f84237aa249d246488d06439acbe0e6e364fd5
untildify: 4.0.0
which: 2.0.2
@ -7680,14 +7680,6 @@ packages:
resolution: {integrity: sha512-8hmiGIJMDlwjg7dlJ4yKGLK8EsYqKgPWbG3b4wjJddKNwc7N7Dpn08Df4szr/sZdMVeOstrdYSsqzX6BYbcB+w==}
dev: true
/time-delta/1.0.0:
resolution: {integrity: sha512-9Njh4IxFsKileZFMTQ01ci1Mt7HlfkkgGSNSsvo2psvSqUedqSDdxS18gI7C9kSjeJ8FSkD4ekA2w5bOZCnu7g==}
engines: {node: '>=12'}
dependencies:
is-node: 1.0.2
numerous: 1.0.3
dev: false
/timsort/0.3.0:
resolution: {integrity: sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=}
dev: true
@ -8267,3 +8259,13 @@ packages:
is-plain-obj: 2.1.0
sort-object-keys: 1.1.3
dev: true
github.com/aminya/time-delta/a6f84237aa249d246488d06439acbe0e6e364fd5:
resolution: {tarball: https://codeload.github.com/aminya/time-delta/tar.gz/a6f84237aa249d246488d06439acbe0e6e364fd5}
name: time-delta
version: 1.0.0
engines: {node: '>=12'}
dependencies:
is-node: 1.0.2
numerous: 1.0.3
dev: false

View File

@ -21,7 +21,7 @@ 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 enLocale from "time-delta/locales/en.js"
import semverValid from "semver/functions/valid"
import { getVersion } from "./default_versions"
@ -129,9 +129,9 @@ export async function main(args: string[]): Promise<number> {
const errorMessages: string[] = []
const timeFormatter = timeDelta.create()
timeDelta.addLocale(enLocale as timeDelta.LocaleData)
let time1: Date
let time2: Date
timeDelta.addLocale(enLocale as timeDelta.Locale)
let time1: number
let time2: number
// installing the specified tools
@ -143,7 +143,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 +165,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 ${timeFormatter.format(time1, time2)}`)
}
}
// 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 +219,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 ${timeFormatter.format(time1, time2)}`)
}
} 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 ${timeFormatter.format(time1, time2)}`)
}
if (successMessages.length === 0 && errorMessages.length === 0) {