This commit is contained in:
parent
0d411428dc
commit
186a7096a4
@ -74,7 +74,6 @@ export async function assertLinesEqual(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getFile = (file: string): TFile => {
|
const getFile = (file: string): TFile => {
|
||||||
console.log("gfbp", window.app.vault.getFileByPath, file)
|
|
||||||
let f = window.app.vault.getFileByPath(file);
|
let f = window.app.vault.getFileByPath(file);
|
||||||
if (!f) {
|
if (!f) {
|
||||||
throw new Error("File does not exist in vault.");
|
throw new Error("File does not exist in vault.");
|
||||||
@ -99,11 +98,8 @@ export async function readFile(
|
|||||||
const fn = getFile.toString();
|
const fn = getFile.toString();
|
||||||
return normalizeEOL(
|
return normalizeEOL(
|
||||||
await doWithApp(page, async (app, args) => {
|
await doWithApp(page, async (app, args) => {
|
||||||
console.log(args);
|
|
||||||
console.log(app.vault.getFileByPath)
|
|
||||||
const gf = eval(`(${args.getFile})`);
|
const gf = eval(`(${args.getFile})`);
|
||||||
console.log("file", gf);
|
const file = gf(args.path);
|
||||||
const file = (eval(args.getFile))(args.path);
|
|
||||||
return await (args.cached ? app.vault.cachedRead(file) : app.vault.read(file));
|
return await (args.cached ? app.vault.cachedRead(file) : app.vault.read(file));
|
||||||
}, {path, cached, getFile: fn})
|
}, {path, cached, getFile: fn})
|
||||||
);
|
);
|
||||||
@ -129,7 +125,6 @@ export async function doWithApp<T = unknown, A = any>(
|
|||||||
const cbStr = callback.toString();
|
const cbStr = callback.toString();
|
||||||
return await page.evaluate<T, {__callback: string, args: A}>(async ({__callback: cb, args}) => {
|
return await page.evaluate<T, {__callback: string, args: A}>(async ({__callback: cb, args}) => {
|
||||||
const func = new Function("args", `return ((${cb}))(window.app, args)`)
|
const func = new Function("args", `return ((${cb}))(window.app, args)`)
|
||||||
console.log(func.toString());
|
|
||||||
return await func(args);
|
return await func(args);
|
||||||
}, {__callback: cbStr, args});
|
}, {__callback: cbStr, args});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user