feat: tasks workflow
This commit is contained in:
@@ -68,7 +68,7 @@ export class FsTaskRepository implements ITaskRepository {
|
||||
};
|
||||
|
||||
await this.#fs.mkdir(folderPath);
|
||||
const filePath = this.taskFilePath(folderPath, newTask);
|
||||
const filePath = this.getFilePath(folderPath, newTask);
|
||||
await this.#fs.writeFile(filePath, serializeTask(newTask));
|
||||
|
||||
return newTask;
|
||||
@@ -77,10 +77,10 @@ export class FsTaskRepository implements ITaskRepository {
|
||||
async update(folderPath: string, task: Task): Promise<void> {
|
||||
const existing = await this.getById(folderPath, task.id);
|
||||
const updatedTask = { ...task, updated: this.#now() };
|
||||
const newPath = this.taskFilePath(folderPath, updatedTask);
|
||||
const newPath = this.getFilePath(folderPath, updatedTask);
|
||||
|
||||
if (existing) {
|
||||
const oldPath = this.taskFilePath(folderPath, existing);
|
||||
const oldPath = this.getFilePath(folderPath, existing);
|
||||
if (oldPath !== newPath) {
|
||||
await this.#fs.deleteFile(oldPath).catch(() => {});
|
||||
}
|
||||
@@ -93,7 +93,7 @@ export class FsTaskRepository implements ITaskRepository {
|
||||
const task = await this.getById(folderPath, id);
|
||||
if (!task) return;
|
||||
|
||||
const filePath = this.taskFilePath(folderPath, task);
|
||||
const filePath = this.getFilePath(folderPath, task);
|
||||
try {
|
||||
await this.#fs.deleteFile(filePath);
|
||||
} catch {
|
||||
@@ -101,7 +101,7 @@ export class FsTaskRepository implements ITaskRepository {
|
||||
}
|
||||
}
|
||||
|
||||
private taskFilePath(folderPath: string, task: Task): string {
|
||||
getFilePath(folderPath: string, task: Task): string {
|
||||
const safeName = task.title
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9\u0400-\u04FF]+/g, "-")
|
||||
|
||||
Reference in New Issue
Block a user