File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,12 @@ describe('getModifiedTime', () => {
172172 expect ( typeof epoch ) . toBe ( 'number' )
173173 expect ( epoch ) . toBeGreaterThan ( 1640995200000 )
174174 } )
175+
176+ it ( 'should return -1 for a file that does not exist on the system' , ( ) => {
177+ const epoch = getModifiedTime ( 'not a path' )
178+
179+ expect ( epoch ) . toStrictEqual ( - 1 )
180+ } )
175181} )
176182
177183describe ( 'findOrCreateDvcYamlFile' , ( ) => {
Original file line number Diff line number Diff line change @@ -36,8 +36,12 @@ export const isDirectory = (path: string): boolean =>
3636
3737export const isFile = ( path : string ) : boolean => checkStats ( path , 'isFile' )
3838
39- export const getModifiedTime = ( path : string ) : number =>
40- lstatSync ( path ) . mtime . getTime ( )
39+ export const getModifiedTime = ( path : string ) : number => {
40+ if ( exists ( path ) ) {
41+ return lstatSync ( path ) . mtime . getTime ( )
42+ }
43+ return - 1
44+ }
4145
4246export const findSubRootPaths = async (
4347 cwd : string ,
You can’t perform that action at this time.
0 commit comments