mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-16 04:43:35 +00:00
refactor: simplify file checks
This commit is contained in:
committed by
Carlos Valente
parent
751c3329f0
commit
367997fd16
@@ -1,4 +1,4 @@
|
||||
import { ProjectFile } from 'ontime-types';
|
||||
import { MaybeString, ProjectFile } from 'ontime-types';
|
||||
|
||||
import { access, rename, stat } from 'fs/promises';
|
||||
import { join } from 'path';
|
||||
@@ -51,13 +51,13 @@ export async function getProjectFiles(): Promise<ProjectFile[]> {
|
||||
* Checks whether a project of a given name exists
|
||||
* @param name
|
||||
*/
|
||||
export async function doesProjectExist(name: string): Promise<boolean> {
|
||||
export async function doesProjectExist(name: string): Promise<MaybeString> {
|
||||
try {
|
||||
const projectFilePath = join(resolveProjectsDirectory, name);
|
||||
const projectFilePath = getPathToProject(name);
|
||||
await access(projectFilePath);
|
||||
return true;
|
||||
return projectFilePath;
|
||||
} catch (_) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user