从typescript

时间:2016-08-01 03:55:57

标签: node.js typescript gulp

我想在部署了使用 typescript angularjs2 应用程序的服务器上执行命令。命令很简单:

java --version

并希望获得该命令的响应。

我不知道,是否有可能。

先谢谢!!

编辑: 得到错误:

zone.js:260 Uncaught EXCEPTION: Error in ./AppComponent class AppComponent - inline template:8:48
ORIGINAL EXCEPTION: ReferenceError: require is not defined
ORIGINAL STACKTRACE:
ReferenceError: require is not defined
    at AppComponent.performCmdOperation (http://localhost:8000/app/app.component.js:43:67)

  

app.component.ts

export class AppComponent{

SelectType = EnumSelectType;
selectedSection: SelectType = EnumSelectType[EnumSelectType.Home];
selectPage(selectType:EnumSelectType) {
    console.log('Global : ' + EnumSelectType[selectType]);
    this.selectedSection = EnumSelectType[selectType];
    console.log(this.selectedSection + ' selected');
}

performCmdOperation(){
    console.log('in perform action');
    const exec = require('sdk/system/child_process').exec; //this is the point where I'm getting error.
    exec('ipconfig', (error, stdout, stderr) => {
        if (error) {
            console.error(`exec error: ${error}`);
            return;
        }
        console.log(`stdout: ${stdout}`);
        console.log(`stderr: ${stderr}`);
    });
}

请帮我找到问题。使用' child_process' 是否需要import missing or any dependency

我当前的依赖是

"bootstrap": "^3.3.6",

"@angular/common": "2.0.0-rc.4",
"@angular/compiler": "2.0.0-rc.4",
"@angular/core": "2.0.0-rc.4",
"@angular/http": "2.0.0-rc.4",
"@angular/platform-browser": "2.0.0-rc.4",
"@angular/platform-browser-dynamic": "2.0.0-rc.4",
"@angular/router": "2.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.1",
"@angular/upgrade": "2.0.0-rc.4",

"systemjs": "0.19.27",
"es6-shim": "^0.35.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12"

如果需要修改 gulpfile.ts 。请指导' child_process'将添加到gulpfile中。

0 个答案:

没有答案