You can use the lutimesSync
function from the fs-extra
library to change the access and modification times of a file in a Typescript project.
Here is an example code snippet:
index.ts197 chars9 lines
In this example, we import the fs-extra
library using import fs from 'fs-extra'
. We then define the filePath
variable to point to the file whose access and modification times we want to change.
We create a new Date
object to represent the current time and set the accessTime
and modificationTime
variables to the same value.
Finally, we call the lutimesSync
function with the filePath
, accessTime
, and modificationTime
arguments to update the file's access and modification times. The lutimesSync
function is synchronous and will block until the operation completes.
gistlibby LogSnag