@@ -8,6 +8,7 @@ import path from 'path'
88import { promisify } from 'util'
99
1010import { recursiveDelete } from '../lib/recursive-delete'
11+ import { fileExists } from '../lib/file-exists'
1112import * as Log from './output/log'
1213import { PageInfo } from './utils'
1314
@@ -17,7 +18,6 @@ const DIR_FILES_NAME = 'files'
1718const MAX_SHUTTLES = 3
1819
1920const mkdirp = promisify ( mkdirpModule )
20- const fsExists = promisify ( fs . exists )
2121const fsReadFile = promisify ( fs . readFile )
2222const fsWriteFile = promisify ( fs . writeFile )
2323const fsCopyFile = promisify ( fs . copyFile )
@@ -196,7 +196,7 @@ export class FlyingShuttle {
196196
197197 const found =
198198 this . shuttleBuildId &&
199- ( await fsExists ( path . join ( this . shuttleDirectory , CHUNK_GRAPH_MANIFEST ) ) )
199+ ( await fileExists ( path . join ( this . shuttleDirectory , CHUNK_GRAPH_MANIFEST ) ) )
200200
201201 if ( found ) {
202202 Log . info ( 'flying shuttle is docked' )
@@ -260,7 +260,7 @@ export class FlyingShuttle {
260260 await Promise . all (
261261 [ ...allFiles ] . map ( async file => {
262262 const filePath = path . join ( path . dirname ( this . pagesDirectory ) , file )
263- const exists = await fsExists ( filePath )
263+ const exists = await fileExists ( filePath )
264264 if ( ! exists ) {
265265 fileChanged . set ( file , true )
266266 return
@@ -310,7 +310,7 @@ export class FlyingShuttle {
310310 DIR_FILES_NAME ,
311311 'serverless/pages-manifest.json'
312312 )
313- if ( ! ( await fsExists ( savedPagesManifest ) ) ) return
313+ if ( ! ( await fileExists ( savedPagesManifest ) ) ) return
314314
315315 const saved = JSON . parse ( await fsReadFile ( savedPagesManifest , 'utf8' ) )
316316 const currentPagesManifest = path . join (
@@ -355,7 +355,7 @@ export class FlyingShuttle {
355355 const filesExists = await Promise . all (
356356 files
357357 . map ( f => path . join ( this . shuttleDirectory , DIR_FILES_NAME , f ) )
358- . map ( f => fsExists ( f ) )
358+ . map ( f => fileExists ( f ) )
359359 )
360360 if ( ! filesExists . every ( Boolean ) ) {
361361 Log . warn ( `unable to locate files for ${ page } in shuttle` )
@@ -368,7 +368,7 @@ export class FlyingShuttle {
368368 files . map ( async recallFileName => {
369369 if ( ! rewriteRegex . test ( recallFileName ) ) {
370370 const recallPath = path . join ( this . distDirectory , recallFileName )
371- const recallPathExists = await fsExists ( recallPath )
371+ const recallPathExists = await fileExists ( recallPath )
372372
373373 if ( ! recallPathExists ) {
374374 await mkdirp ( path . dirname ( recallPath ) )
@@ -391,7 +391,7 @@ export class FlyingShuttle {
391391 `${ this . buildId } /`
392392 )
393393 const recallPath = path . join ( this . distDirectory , newFileName )
394- const recallPathExists = await fsExists ( recallPath )
394+ const recallPathExists = await fileExists ( recallPath )
395395 if ( ! recallPathExists ) {
396396 await mkdirp ( path . dirname ( recallPath ) )
397397 await fsCopyFile (
@@ -428,7 +428,7 @@ export class FlyingShuttle {
428428 await mkdirp ( this . shuttleDirectory )
429429
430430 const nextManifestPath = path . join ( this . distDirectory , CHUNK_GRAPH_MANIFEST )
431- if ( ! ( await fsExists ( nextManifestPath ) ) ) {
431+ if ( ! ( await fileExists ( nextManifestPath ) ) ) {
432432 Log . warn ( 'could not find shuttle payload :: shuttle will not be docked' )
433433 return
434434 }
0 commit comments