| 56 | // eslint-disable-next-line @typescript-eslint/naming-convention |
| 57 | export class filepath { |
| 58 | static async stats(name: string | undefined | Promise<string | undefined>, baseFolder?: string): Promise<[string, Stats | undefined] | [undefined, undefined]> { |
| 59 | if (is.promise(name)) { |
| 60 | name = await name; |
| 61 | } |
| 62 | |
| 63 | // if the value isn't a string or has a newline, it ain't a file name |
| 64 | if (!name || name.indexOf('\n') !== -1) { |
| 65 | return [undefined, undefined]; |
| 66 | } |
| 67 | |
| 68 | // if we've been given a baseFolder, expand that, otherwise just normalize the value. |
| 69 | name = baseFolder ? resolve(baseFolder, name) : normalize(name); |
| 70 | |
| 71 | return [name, await stat(name).catch(returns.undefined)]; |
| 72 | } |
| 73 | |
| 74 | static async info(name: string | undefined | Promise<string | undefined>, baseFolder?: string, executableExtensions: Set<string> = process.platform === 'win32' ? new Set(['.exe'/* ,'.cmd','.bat' */]) : new Set()): Promise<undefined | File | Folder> { |
| 75 | const [fullPath, stats] = await filepath.stats(name, baseFolder); |