Skip to content

Commit

Permalink
feat: log fetch, build & test steps duration
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jun 27, 2023
1 parent 2d8a99c commit b7b3db3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/main/js/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {$, fs, INI, fetch, tempy} from 'zx-extra'

export const fetchPkg = async (pkg) => {
const id = `${pkg.name}@${pkg.version}`
const now = Date.now()

try {
const cwd = pkg.absPath
Expand All @@ -11,8 +12,9 @@ export const fetchPkg = async (pkg) => {
const bearerToken = getBearerToken(npmRegistry, npmToken, npmConfig)
const authorization = bearerToken ? `--header='Authorization: ${bearerToken}'` : ''
log({pkg})(`fetching '${id}' from ${npmRegistry}`)
await $.raw`wget --timeout=10 --connect-timeout=5 ${authorization} -qO- ${tarballUrl} | tar -xvz --strip-components=1 --exclude='package.json' -C ${cwd}`
await $.raw`wget --timeout=15 --connect-timeout=5 ${authorization} -qO- ${tarballUrl} | tar -xvz --strip-components=1 --exclude='package.json' -C ${cwd}`

log({pkg})(`fetch duration '${id}': ${Date.now() - now}`)
pkg.fetched = true
} catch (e) {
log({pkg, level: 'warn'})(`fetching '${id}' failed`, e)
Expand Down
6 changes: 5 additions & 1 deletion src/main/js/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ export const run = async ({cwd = process.cwd(), env, flags = {}} = {}) => within

export const runCmd = async (pkg, name) => {
const cmd = tpl(pkg.config[name], {...pkg, ...pkg.context})
const now = Date.now()

if (cmd) {
log({pkg})(`run ${name} '${cmd}'`)
return $.o({cwd: pkg.absPath, quote: v => v, preferLocal: true})`${cmd}`
const result = await $.o({cwd: pkg.absPath, quote: v => v, preferLocal: true})`${cmd}`

log({pkg})(`duration ${name}: ${Date.now() - now}`)
return result
}
}

Expand Down

0 comments on commit b7b3db3

Please sign in to comment.