Skip to content

Commit

Permalink
ref/ add node/electron module import as exemple : fs and remote
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime GRIS committed Apr 15, 2018
1 parent 54a3d6c commit e3ad12d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/app/providers/electron.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@ import { Injectable } from '@angular/core';

// If you import a module but never use any of the imported values other than as TypeScript types,
// the resulting javascript file will look as if you never imported the module at all.
import { ipcRenderer, webFrame } from 'electron';
import { ipcRenderer, webFrame, remote } from 'electron';
import * as childProcess from 'child_process';
import * as fs from 'fs';

@Injectable()
export class ElectronService {

ipcRenderer: typeof ipcRenderer;
childProcess: typeof childProcess;
webFrame: typeof webFrame;
remote: typeof remote;
childProcess: typeof childProcess;
fs: typeof fs;

constructor() {
// Conditional imports
if (this.isElectron()) {
this.ipcRenderer = window.require('electron').ipcRenderer;
this.childProcess = window.require('child_process');
this.webFrame = window.require('electron').webFrame;
this.remote = window.require('electron').remote;

this.childProcess = window.require('child_process');
this.fs = window.require('fs');
}
}

Expand Down

0 comments on commit e3ad12d

Please sign in to comment.