在Electron中打包的Angular app中运行shell脚本

问题描述 投票:2回答:1

我在Electron中打包了Angular 2应用程序。我想知道是否可以从该应用程序运行shell脚本。

谢谢你的帮助。

angular shell electron
1个回答
3
投票

我能够使用ngx-childprocess实现这一点

分3个步骤:

  1. 在你的电子/角度应用程序安装ngx-childprocess yarn add ngx-childprocess or npm install ngx-childprocess --save
  2. 将gx-childprocess添加到app.module中 imports: [ NgxChildProcessModulem ....
  3. 运行脚本(在这种情况下我运行java jar) import { ChildProcessService } from 'ngx-childprocess'; ... export class AppComponent { constructor(private childProcessService: ChildProcessService) { console.log('isElectronApp ' + childProcessService.isElectronApp); let options: string[] = []; childProcessService.childProcess.exec('java -jar child-process-test-1.0.jar', options, (data) => {console.log(data);}); } }
© www.soinside.com 2019 - 2024. All rights reserved.