projeto-hit/backend/src/helpers/CreationTime.ts

24 lines
480 B
TypeScript
Raw Normal View History

2022-12-23 16:35:07 +00:00
// require fs module
const fs = require("fs");
// Delete a directory and its children
export const creationTime = (sourcePath: string) => {
if (fs.existsSync(sourcePath)) {
try {
const { birthtime } = fs.statSync(sourcePath)
return birthtime
} catch (error) {
console.log(`There was an error on trying get de file/directory creation info from ${sourcePath}: `, error)
}
}
return
}