🌳
pt0/serverF/libFs/getIsDirF.mts
1import * as _ from 'lodash-es'
2import fs from 'fs'
4import { type absFileDirPath } from '../../ptDirF.mts'
6export const getIsDir = async (path: string): Promise<boolean | null> => {
7 try {
8 return (await fs.promises.stat(path)).isDirectory()
9 } catch (err) {
10 if ((err as NodeJS.ErrnoException).code == 'ENOENT') return null
11 throw err
12 }
15export const lsFilePathsRec = async (dir: string): Promise<absFileDirPath[]> => {
16 let filePaths = await getFilesRec(dir)
18 filePaths = _.filter(filePaths, (path: absFileDirPath) => {
19 const pathA = path.split('/')
21 if (_.intersection(pathA, globallyIgnoredPaths).length > 0) {
22 return false
23 }
24 return true
25 })
26 return filePaths