Skip to content

Commit

Permalink
perf: globally install pkg-size (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber authored Dec 12, 2020
1 parent 1049313 commit 17d4a79
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10869,6 +10869,8 @@ async function isFileTracked(filePath) {
return exitCode === 0;
}

let pkgSizeInstalled = false;

async function buildRef({
ref,
buildCommand,
Expand Down Expand Up @@ -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));
Expand Down
11 changes: 10 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ async function isFileTracked(filePath) {
return exitCode === 0;
}

let pkgSizeInstalled = false;

async function buildRef({
ref,
buildCommand,
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 17d4a79

Please sign in to comment.