electron-react-boilerplate / electron-react-boilerplate

A Foundation for Scalable Cross-Platform Apps

Home Page:https://electron-react-boilerplate.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

access assets after installed mac

supun19 opened this issue · comments

Summary

I have assets, and when I package them, I add them to the extraResources as well. However, when I try to get the path of the assets folder using process.resourcesPath, it gives me the wrong path. It provides the project folder path instead of the installed application path

"/Users/usename/electron-react-boilerplate/release/build/mac/TestApp.app/Contents/Resources"

This is working well development environment

    const { sourcefile, filename } = data;
    const videoPath = app.getPath('exe');
    const pathSep = path.sep;
    let source;
    if (process.env.NODE_ENV === 'development') {
      source = path.join('assets', 'videos', sourcefile);
    } else {
      source = path.join(
        process.resourcesPath,
        'app.asar',
        'assets',
        'videos',
        sourcefile,
      );
    }
    const pth = path.join(app.getPath('userData'), filename);
    console.log(source, pth);
    const res = fs.copyFileSync(source, pth);
    return { result: res };

anyone have idea