2017-03-05 12 views
1

コマンドライン引数を使用して環境変数の値を渡すことはできますか?コマンドライン引数を使用して環境変数を設定する

など。

aurelia_project /環境/ prod.ts

export default { 
    debug: false, 
    testing: false, 
    // $buildVersion$ should be replaced during build with the actual value 
    buildVersion: $buildVersion$ 
}; 

想像コマンド:au build --env prod --buildVersion 1.1.1


編集私は私のビルド・サーバーによって生成されたバージョン番号を設定したいのですが
これは現時点では可能ではないようですので、Aureliasで機能リクエストを作成しました

答えて

0

proposed by AStokerとして、私はこの次のように解決することができました:

aurelia_project /環境/ prod.ts

export default { 
    debug: false, 
    testing: false, 
    buildVersion: {buildVersion} // <-- Will be replace during build 
}; 

aurelia_projectを/ transpile.js

// ... 
import * as replace from 'gulp-replace'; 

function configureEnvironment() { 
    let env = CLIOptions.getEnvironment(); 
    let buildVersion = CLIOptions.getFlagValue('buildVersion') || '0.0.0'; 

    return gulp.src(`aurelia_project/environments/${env}.ts`) 
     .pipe(changedInPlace({firstPass: true})) 
     .pipe(replace('{buildVersion}', buildVersion)) // <-- Replacement happens here 
     .pipe(rename('environment.ts')) 
     .pipe(gulp.dest(project.paths.root)); 
} 
// ... 

コマンドラインコール:au build --buildVersion 1.1.1

関連する問題