@lxixlxix/electron-view-resource v2.0.0
ELECTRON-VIEW-RESOURCE
Example usage with angular-electron (TypeScript).
INSTALL
npm i -S @lxixlxix/electron-view-resourceAPI
ResourceManager(options)
Added in: v1.0.0
options: <object>prodDirSuffix: <string>Default:distdevDirSuffix: <string>Default:src
- Returns:
<ResourceManager> Instance
resource.isDev()
Added in: v1.0.0
- Returns:
<boolean>
Returns true if the current environment is development, false otherwise.
Not requiring additional setup, or environmental variables.
resource.getResourceDir()
Added in: v1.0.0
- Returns:
<string>
Returns app.getAppPath() concated with src if the current environment is the development environment, dist otherwise.
Example return value in dev env:
G:\{repo-of-your-app}\src
Example return value in prod env (packed + unpacked):
C:\Users\{your-username}\AppData\Local\Temp\{?random}.tmp\app\resources\app.asar\dist
or
G:\path\to\your\app\resources\app.asar\dist
resource.exist(path)
Added in: v1.0.0
path: <string>- Returns:
<boolean>
Synchronously returns true if the path exists, false otherwise. Basically the alias of fs.existsSync(path),
but it'll automatically concat the given path to resource.getResourceDir(), so adding that is not acceptable.
The path should be always relative to the project source directory.
TODOs
- Support more general use cases (including plain electron projects).
- Options for fallback url, to download the missing files through https.
Issues
- Only tested with the angular-electron wrapper.
- Will break for apps that are not using ASAR.