Small refactoring
This commit is contained in:
parent
88e9eb714c
commit
d34166eac3
|
@ -60,7 +60,7 @@ export default class AppUtils {
|
||||||
return this.getFileByPathOrThrow(areaFileName + ".md");
|
return this.getFileByPathOrThrow(areaFileName + ".md");
|
||||||
} else {
|
} else {
|
||||||
const areaFileName = strLink.replace("[[", "").replace("]]", "");
|
const areaFileName = strLink.replace("[[", "").replace("]]", "");
|
||||||
return this.getFileByName(areaFileName + ".md");
|
return this.getFileByNameOrThrow(areaFileName + ".md");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,9 +98,12 @@ export default class AppUtils {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO rename and add `orThrow`
|
getFileByNameOrThrow(parentFileName: string): TFile {
|
||||||
getFileByName(parentFileName: string): TFile {
|
let tFile = this.app.vault.getMarkdownFiles().filter(f => f.name == parentFileName)[0];
|
||||||
return this.app.vault.getMarkdownFiles().filter(f => f.name == parentFileName)[0];
|
if (!tFile) {
|
||||||
|
throw new Error("File not found by name " + parentFileName);
|
||||||
|
}
|
||||||
|
return tFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
getFileByPathOrThrow(filePath: string): TFile {
|
getFileByPathOrThrow(filePath: string): TFile {
|
||||||
|
|
Loading…
Reference in New Issue