From 17d4a7912f664e93f7d1838adb55b716620de49e Mon Sep 17 00:00:00 2001 From: hiroki Date: Sat, 12 Dec 2020 18:37:59 -0500 Subject: [PATCH] perf: globally install pkg-size (#11) --- dist/index.js | 11 ++++++++++- src/index.js | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 346ade0..aec0b03 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10869,6 +10869,8 @@ async function isFileTracked(filePath) { return exitCode === 0; } +let pkgSizeInstalled = false; + async function buildRef({ ref, buildCommand, @@ -10918,8 +10920,15 @@ async function buildRef({ } } + if (!pkgSizeInstalled) { + core.info('Installing pkg-size globally'); + await exec$2('yarn global add pkg-size'); + core.addPath((await exec$2('yarn global bin')).stdout.trim()); + pkgSizeInstalled = true; + } + core.info('Getting package size'); - const result = await exec$2('npx pkg-size --json', {cwd}).catch(error => { + const result = await exec$2('pkg-size --json', {cwd}).catch(error => { throw new Error(`Failed to determine package size: ${error.message}`); }); core.debug(JSON.stringify(result, null, 4)); diff --git a/src/index.js b/src/index.js index 02eeead..c4c3211 100644 --- a/src/index.js +++ b/src/index.js @@ -60,6 +60,8 @@ async function isFileTracked(filePath) { return exitCode === 0; } +let pkgSizeInstalled = false; + async function buildRef({ ref, buildCommand, @@ -109,8 +111,15 @@ async function buildRef({ } } + if (!pkgSizeInstalled) { + core.info('Installing pkg-size globally'); + await exec('yarn global add pkg-size'); + core.addPath((await exec('yarn global bin')).stdout.trim()); + pkgSizeInstalled = true; + } + core.info('Getting package size'); - const result = await exec('npx pkg-size --json', {cwd}).catch(error => { + const result = await exec('pkg-size --json', {cwd}).catch(error => { throw new Error(`Failed to determine package size: ${error.message}`); }); core.debug(JSON.stringify(result, null, 4));