@@ -75,53 +75,14 @@ export class ElectronBuilder extends BrowserBuilder {
7575 ) ;
7676 }
7777
78- installElectronApplicationDependencies ( builderConfig : BuilderConfiguration < ElectronBuilderSchema > ) : Observable < BuildEvent > {
79-
80-
81- return new Observable < BuildEvent > ( obs => {
82- const electronProjectPath : Path = resolve ( this . context . workspace . root , normalize ( builderConfig . options . electronProjectDir ) ) ;
83- const electronNodeModulesPath = getSystemPath ( resolve ( electronProjectPath , normalize ( 'node_modules' ) ) ) ;
84- rimraf ( electronNodeModulesPath , { rmdir : rmdir } , ( error ) => {
85- if ( error ) {
86- this . context . logger . info ( error . message ) ;
87- obs . error ( error ) ;
88- obs . next ( { success : false } ) ;
89- obs . complete ( ) ;
90- }
91- } ) ;
92- let electronBuilderExecutable : string ;
93- if ( process . platform === 'win32' ) {
94- electronBuilderExecutable = 'electron-builder.cmd' ;
95- } else {
96- electronBuilderExecutable = 'electron-builder' ;
97- }
98- const electronBuilderExecutablePath : string = getSystemPath ( join ( this . context . workspace . root , 'node_modules' , '.bin' , electronBuilderExecutable ) ) ;
99- const childProcess : ChildProcess = spawn ( electronBuilderExecutablePath , [ 'install-app-deps' ] , { cwd :getSystemPath ( electronProjectPath ) } ) ;
100- const killForkedProcess = ( ) => {
101- if ( childProcess && childProcess . pid ) {
102- treeKill ( childProcess . pid , 'SIGTERM' ) ;
103- }
104- } ;
105- // Handle child process exit.
106- const handleChildProcessExit = ( code ) => {
107- killForkedProcess ( ) ;
108- if ( code && code !== 0 ) {
109- obs . error ( ) ;
110- }
111- obs . next ( { success : true } ) ;
112- obs . complete ( ) ;
113- } ;
114- childProcess . once ( 'exit' , handleChildProcessExit ) ;
115- childProcess . once ( 'SIGINT' , handleChildProcessExit ) ;
116- childProcess . once ( 'uncaughtException' , handleChildProcessExit ) ;
117- const handleParentProcessExit = ( ) => {
118- killForkedProcess ( ) ;
119- } ;
120- process . once ( 'exit' , handleParentProcessExit ) ;
121- process . once ( 'SIGINT' , handleParentProcessExit ) ;
122- process . once ( 'uncaughtException' , handleParentProcessExit ) ;
123- } )
78+ installElectronApplicationDependencies ( builderConfig : BuilderConfiguration < ElectronBuilderSchema > ) : Observable < BuildEvent > {
12479
80+ return runModuleAsObservableFork (
81+ getSystemPath ( this . context . workspace . root ) ,
82+ '@ng-electron-devkit/builders/dist/electron/build-electron' ,
83+ 'installAppDeps' ,
84+ [ ] ,
85+ ) ;
12586 }
12687}
12788
0 commit comments