Skip to content

Commit 1aa8894

Browse files
committed
ディレクトリも含めるように変更
1 parent 55f88c7 commit 1aa8894

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/lib/file-system-repo.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export class FileSystemRepo {
206206
}
207207

208208
private parseFilename(filename: string) {
209-
return path.basename(filename, ".md");
209+
return filename.split(".md")[0];
210210
}
211211

212212
private getFilePath(uuid: string, remote: boolean = false) {
@@ -217,11 +217,11 @@ export class FileSystemRepo {
217217
return (
218218
await fs.readdir(
219219
this.getRootOrRemotePath(remote),
220-
FileSystemRepo.fileSystemOptions()
220+
FileSystemRepo.fileSystemOptions(),
221221
)
222222
).filter(
223223
(itemFilename) =>
224-
/\.md$/.test(itemFilename) && !itemFilename.startsWith(".remote/")
224+
/\.md$/.test(itemFilename) && !itemFilename.startsWith(".remote/"),
225225
);
226226
}
227227

@@ -239,7 +239,7 @@ export class FileSystemRepo {
239239
const basename = `${prefix}${suffix}`;
240240
const filenameCandidate = this.getFilename(basename);
241241
const found = itemFilenames.find(
242-
(filename) => filename === filenameCandidate
242+
(filename) => filename === filenameCandidate,
243243
);
244244
if (!found) {
245245
return basename;
@@ -259,27 +259,27 @@ export class FileSystemRepo {
259259
private async setItemData(
260260
fileContent: FileContent,
261261
remote: boolean = false,
262-
basename: string | null = null
262+
basename: string | null = null,
263263
) {
264264
if (!fileContent.id) {
265265
return;
266266
}
267267
const filepath = this.getFilePath(
268268
basename || this.defaultBasename(fileContent),
269-
remote
269+
remote,
270270
);
271271
const data = fileContent.toSaveFormat();
272272
await fs.writeFile(filepath, data, FileSystemRepo.fileSystemOptions());
273273
}
274274

275275
private async getItemData(
276276
itemFilename: string,
277-
remote: boolean = false
277+
remote: boolean = false,
278278
): Promise<FileContent | null> {
279279
try {
280280
const fileContent = await fs.readFile(
281281
path.join(this.getRootOrRemotePath(remote), itemFilename),
282-
FileSystemRepo.fileSystemOptions()
282+
FileSystemRepo.fileSystemOptions(),
283283
);
284284
return FileContent.read(fileContent);
285285
} catch (err: any) {
@@ -290,7 +290,7 @@ export class FileSystemRepo {
290290
private async syncItem(
291291
item: Item,
292292
beforeSync: boolean = false,
293-
forceUpdate: boolean = false
293+
forceUpdate: boolean = false,
294294
) {
295295
const fileContent = FileContent.fromItem(item);
296296

@@ -302,7 +302,7 @@ export class FileSystemRepo {
302302
const basename = localResult?.name || null;
303303
const remoteFileContent = await this.getItemData(
304304
this.getFilename(item.id),
305-
true
305+
true,
306306
);
307307

308308
if (data === null || remoteFileContent?.equals(data) || forceUpdate) {
@@ -324,7 +324,7 @@ export class FileSystemRepo {
324324
async saveItem(
325325
item: Item,
326326
beforeSync: boolean = false,
327-
forceUpdate: boolean = false
327+
forceUpdate: boolean = false,
328328
) {
329329
await this.syncItem(item, beforeSync, forceUpdate);
330330
}
@@ -452,7 +452,7 @@ export class FileSystemRepo {
452452
await fs.writeFile(
453453
newFilePath,
454454
newData,
455-
FileSystemRepo.fileSystemOptions()
455+
FileSystemRepo.fileSystemOptions(),
456456
);
457457
}
458458

0 commit comments

Comments
 (0)