This repository was archived by the owner on Jan 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -246,17 +246,22 @@ class Builder {
246246 } ;
247247 }
248248
249- async cleanupDotNext ( ) : Promise < void [ ] > {
249+ async cleanupDotNext ( ) : Promise < void > {
250250 const dotNextDirectory = join ( path . resolve ( this . nextConfigDir ) , ".next" ) ;
251- const fileItems = await fse . readdir ( dotNextDirectory ) ;
252251
253- return Promise . all (
254- fileItems
255- . filter (
256- fileItem => fileItem !== "cache" // avoid deleting the cache folder as that would lead to slow builds!
257- )
258- . map ( fileItem => fse . remove ( join ( dotNextDirectory , fileItem ) ) )
259- ) ;
252+ const exists = await fse . pathExists ( dotNextDirectory ) ;
253+
254+ if ( exists ) {
255+ const fileItems = await fse . readdir ( dotNextDirectory ) ;
256+
257+ await Promise . all (
258+ fileItems
259+ . filter (
260+ fileItem => fileItem !== "cache" // avoid deleting the cache folder as that would lead to slow builds!
261+ )
262+ . map ( fileItem => fse . remove ( join ( dotNextDirectory , fileItem ) ) )
263+ ) ;
264+ }
260265 }
261266
262267 async build ( ) : Promise < void > {
Original file line number Diff line number Diff line change @@ -61,10 +61,10 @@ describe("Builder Tests", () => {
6161
6262 it ( "output directory is cleanup before building" , ( ) => {
6363 expect ( fseEmptyDirSpy ) . toBeCalledWith (
64- expect . stringContaining ( ".test_sls_next_output/ default-lambda" )
64+ expect . stringContaining ( join ( ".test_sls_next_output" , " default-lambda") )
6565 ) ;
6666 expect ( fseEmptyDirSpy ) . toBeCalledWith (
67- expect . stringContaining ( ".test_sls_next_output/ api-lambda" )
67+ expect . stringContaining ( join ( ".test_sls_next_output" , " api-lambda") )
6868 ) ;
6969 } ) ;
7070 } ) ;
You can’t perform that action at this time.
0 commit comments