Possible screenshot path error fixed

This commit is contained in:
Manoj Vivek 2022-12-03 13:46:46 +05:30
parent 464f81492f
commit 1ae8e60e04
2 changed files with 3 additions and 5 deletions

View file

@ -12,7 +12,7 @@ import path from 'path';
import { app, BrowserWindow, shell, ipcMain, screen } from 'electron';
import { autoUpdater } from 'electron-updater';
import log from 'electron-log';
import { IPC_MAIN_CHANNELS } from 'common/constants';
import { IPC_MAIN_CHANNELS } from '../common/constants';
import MenuBuilder from './menu';
import { resolveHtmlPath } from './util';
import { BROWSER_SYNC_HOST, initInstance } from './browser-sync';

View file

@ -2,6 +2,7 @@ import { Device } from 'common/deviceList';
import { ipcMain, shell, webContents } from 'electron';
import { writeFile, ensureDir } from 'fs-extra';
import path from 'path';
import os from 'os';
export interface ScreenshotArgs {
webContentsId: number;
@ -18,10 +19,7 @@ const quickScreenshot = async (
): Promise<ScreenshotResult> => {
const { webContentsId } = arg;
const image = await webContents.fromId(webContentsId).capturePage();
const dir = path.join(
process.env.HOME || '.',
`/Desktop/Responsively-Screenshots`
);
const dir = path.join(os.homedir(), `Desktop/Responsively-Screenshots`);
const filePath = path.join(dir, `/screenshot-${Date.now()}.jpeg`);
await ensureDir(dir);
await writeFile(filePath, image.toJPEG(100));