Skip to content

Commit 19222a0

Browse files
committed
fix dirname usage
1 parent 1f80657 commit 19222a0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

dev-packages/size-limit-gh-action/index.mjs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const SIZE_LIMIT_HEADING = '## size-limit report 📦 ';
1616
const ARTIFACT_NAME = 'size-limit-action';
1717
const RESULTS_FILE = 'size-limit-results.json';
1818

19+
function getResultsFilePath() {
20+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
21+
return path.resolve(__dirname, RESULTS_FILE);
22+
}
23+
1924
const { getInput, setFailed } = core;
2025

2126
async function fetchPreviousComment(octokit, repo, pr) {
@@ -46,7 +51,7 @@ async function execSizeLimit() {
4651
}
4752

4853
async function run() {
49-
const resultsFilePath = path.resolve(__dirname, RESULTS_FILE);
54+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
5055

5156
try {
5257
const { payload, repo } = context;
@@ -62,7 +67,7 @@ async function run() {
6267

6368
const octokit = getOctokit(githubToken);
6469
const limit = new SizeLimit();
65-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
70+
const resultsFilePath = getResultsFilePath();
6671

6772
// If we have no comparison branch, we just run size limit & store the result as artifact
6873
if (!comparisonBranch) {
@@ -178,7 +183,7 @@ async function run() {
178183
}
179184

180185
async function runSizeLimitOnComparisonBranch() {
181-
const resultsFilePath = path.resolve(__dirname, RESULTS_FILE);
186+
const resultsFilePath = getResultsFilePath();
182187

183188
const limit = new SizeLimit();
184189
const artifactClient = artifact.create();

0 commit comments

Comments
 (0)