我有一个打包在Electron中的Angular 2应用程序。我想知道是否可能从该应用程序运行shell脚本。
感谢您的任何帮助。
in your electron/angular app install ngx-childprocess
yarn add ngx-childprocess
or
npm install ngx-childprocess --save
add gx-childprocess into app.module
imports: [
NgxChildProcessModulem
....
run the script (in this case I am running 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);});
}
}