2.0.0 • Published 6 years ago

@lxixlxix/electron-view-resource v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

ELECTRON-VIEW-RESOURCE

example Example usage with angular-electron (TypeScript).

INSTALL

npm i -S @lxixlxix/electron-view-resource

API

ResourceManager(options)

Added in: v1.0.0

  • options: <object>
    • prodDirSuffix: <string> Default: dist
    • devDirSuffix: <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.
2.0.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago