@@ -16,8 +16,6 @@ const SIZE_LIMIT_HEADING = '## size-limit report 📦 ';
16
16
const ARTIFACT_NAME = 'size-limit-action' ;
17
17
const RESULTS_FILE = 'size-limit-results.json' ;
18
18
19
- const RESULTS_FILE_PATH = path . resolve ( __dirname , RESULTS_FILE ) ;
20
-
21
19
const { getInput, setFailed } = core ;
22
20
23
21
async function fetchPreviousComment ( octokit , repo , pr ) {
@@ -48,6 +46,8 @@ async function execSizeLimit() {
48
46
}
49
47
50
48
async function run ( ) {
49
+ const resultsFilePath = path . resolve ( __dirname , RESULTS_FILE ) ;
50
+
51
51
try {
52
52
const { payload, repo } = context ;
53
53
const pr = payload . pull_request ;
@@ -96,7 +96,7 @@ async function run() {
96
96
downloadPath : __dirname ,
97
97
} ) ;
98
98
99
- base = JSON . parse ( await fs . readFile ( RESULTS_FILE_PATH , { encoding : 'utf8' } ) ) ;
99
+ base = JSON . parse ( await fs . readFile ( resultsFilePath , { encoding : 'utf8' } ) ) ;
100
100
101
101
if ( ! artifacts . isLatest ) {
102
102
baseIsNotLatest = true ;
@@ -178,20 +178,22 @@ async function run() {
178
178
}
179
179
180
180
async function runSizeLimitOnComparisonBranch ( ) {
181
+ const resultsFilePath = path . resolve ( __dirname , RESULTS_FILE ) ;
182
+
181
183
const limit = new SizeLimit ( ) ;
182
184
const artifactClient = artifact . create ( ) ;
183
185
184
186
const { output : baseOutput } = await execSizeLimit ( ) ;
185
187
186
188
try {
187
189
const base = limit . parseResults ( baseOutput ) ;
188
- await fs . writeFile ( RESULTS_FILE_PATH , JSON . stringify ( base ) , 'utf8' ) ;
190
+ await fs . writeFile ( resultsFilePath , JSON . stringify ( base ) , 'utf8' ) ;
189
191
} catch ( error ) {
190
192
core . error ( 'Error parsing size-limit output. The output should be a json.' ) ;
191
193
throw error ;
192
194
}
193
195
194
- const globber = await glob . create ( RESULTS_FILE_PATH , {
196
+ const globber = await glob . create ( resultsFilePath , {
195
197
followSymbolicLinks : false ,
196
198
} ) ;
197
199
const files = await globber . glob ( ) ;
0 commit comments