This commit is contained in:
parent
0751d1da98
commit
7a1ab0ceaf
@ -24,14 +24,21 @@ export function getExe(): string {
|
|||||||
if (process.platform == "darwin") {
|
if (process.platform == "darwin") {
|
||||||
throw new Error("use a non-toy operating system, dumbass");
|
throw new Error("use a non-toy operating system, dumbass");
|
||||||
}
|
}
|
||||||
const possibleDirs = ["/opt/Obsidian", "/usr/lib/Obsidian", "/opt/obsidian", "/usr/lib/obsidian", "/var/lib/flatpak/app/md.obsidian.Obsidian/current/active/files", "/snap/obsidian/current"];
|
const possibleDirs = [
|
||||||
|
"/opt/Obsidian",
|
||||||
|
"/usr/lib/Obsidian",
|
||||||
|
"/opt/obsidian",
|
||||||
|
"/usr/lib/obsidian",
|
||||||
|
"/var/lib/flatpak/app/md.obsidian.Obsidian/current/active/files",
|
||||||
|
"/snap/obsidian/current",
|
||||||
|
];
|
||||||
for (let i = 0; i < possibleDirs.length; i++) {
|
for (let i = 0; i < possibleDirs.length; i++) {
|
||||||
if (existsSync(possibleDirs[i])) {
|
if (existsSync(possibleDirs[i])) {
|
||||||
console.log(execSync(`ls -l ${possibleDirs[i]}`).toString());
|
console.log(execSync(`ls -l ${possibleDirs[i]}`).toString());
|
||||||
return path.join(possibleDirs[i], "resources", "app.asar");
|
return path.join(possibleDirs[i], "resources", "app.asar");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ""
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
async function selectNewVault(page: Page, vaultPath: string) {
|
async function selectNewVault(page: Page, vaultPath: string) {
|
||||||
@ -42,21 +49,20 @@ async function selectNewVault(page: Page, vaultPath: string) {
|
|||||||
const chooser = await promise;
|
const chooser = await promise;
|
||||||
await chooser.setFiles(vaultPath);
|
await chooser.setFiles(vaultPath);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.debug("congratulations, you don't have to choose a vault manually!")
|
console.debug(
|
||||||
|
"congratulations, you don't have to choose a vault manually!"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const obsidianTestFixtures: Fixtures<ObsidianTestFixtures> = {
|
const obsidianTestFixtures: Fixtures<ObsidianTestFixtures> = {
|
||||||
electronApp: [
|
electronApp: [
|
||||||
async ({ obsidian: { vault } }, run) => {
|
async ({}, run) => {
|
||||||
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = "true";
|
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = "true";
|
||||||
console.log("asar located at:", getExe())
|
console.log("asar located at:", getExe());
|
||||||
const electronApp = await electron.launch({
|
const electronApp = await electron.launch({
|
||||||
timeout: 60000,
|
timeout: 60000,
|
||||||
args: [
|
args: [getExe()].filter((a) => !!a) as string[],
|
||||||
getExe(),
|
|
||||||
!!vault && `obsidian://open?path=${encodeURIComponent(vault)}`,
|
|
||||||
].filter((a) => !!a) as string[],
|
|
||||||
});
|
});
|
||||||
electronApp.on("console", async (msg) => {
|
electronApp.on("console", async (msg) => {
|
||||||
console.log(
|
console.log(
|
||||||
@ -73,10 +79,13 @@ const obsidianTestFixtures: Fixtures<ObsidianTestFixtures> = {
|
|||||||
async ({ electronApp, obsidian: { vault } }, run) => {
|
async ({ electronApp, obsidian: { vault } }, run) => {
|
||||||
const windows = electronApp.windows();
|
const windows = electronApp.windows();
|
||||||
console.log("windows", windows);
|
console.log("windows", windows);
|
||||||
const page = windows.last()!;
|
let page = windows.last()!;
|
||||||
await page.waitForEvent("load")
|
await page.waitForEvent("load");
|
||||||
await page.waitForLoadState("domcontentloaded");
|
await page.waitForLoadState("domcontentloaded");
|
||||||
await selectNewVault(page, vault!);
|
await selectNewVault(page, vault!);
|
||||||
|
page = electronApp.windows().last()!;
|
||||||
|
await page.waitForEvent("load");
|
||||||
|
await page.waitForLoadState("domcontentloaded");
|
||||||
await waitForIndexingComplete(await getApp(page));
|
await waitForIndexingComplete(await getApp(page));
|
||||||
page.on("console", async (msg) => {
|
page.on("console", async (msg) => {
|
||||||
console.log(
|
console.log(
|
||||||
|
Loading…
Reference in New Issue
Block a user