以下のように、2つのファイルがロードされています。 properties.jsに設定ファイルを名前で動的にロードしたい。 <%= settings ["build.target.environment"]%>を環境構築オプションの値に置き換えたいと思います。値を置き換えるときはいつでも、私はgruntでコンパイルエラーを取得します。基本的には、タスクを読み込むことができません。タスクが正しく読み込まれていないため、Xタスクが見つかりません。これらの項目を両方とも順番に実行するinitというエイリアスがあります。どのようにビルドオプションをプロパティファイルに入れて、ロードしたい設定を動的に読み込むことができますか?または別のオプションがありますか?私のビルドオプションは、これらのファイルがロードされるときには選択されないようです。設定ファイルを動的に設定する
私には気をつけてください。
properties.js:
module.exports = {
settings: 'config/build.properties',
instance: 'config/environment.<%= settings["build.target.environment"] %>.properties'
}
buildoptions.js:
module.exports = function(grunt) {
grunt.registerTask('buildoptions', 'set build version and repo branch', function() {
var build = grunt.option("build");
var branch = grunt.option("branch") || '';
var environment = grunt.option("environment");
grunt.config('build', build);
grunt.config('branch', branch);
grunt.config('environment', environment)
});
};
aliases.json:あなたはgrunt.option
値にアクセスするローカル変数を設定する必要はありません
"init": [
"buildoptions",
"properties"
]
ビルドオプションファイルに環境情報は必要ありませんか? –
これは、/var/jenkins_home/workspace/DEV22/grunt/config/properties.js:3 インスタンス: 'config/environment。<%= grunt.option(' environment ')%>。プロパティ' 読み込み中にエラーが発生しました。 "Gruntfile.js"タスク... [31mERROR [39m –
] \ '環境\'で単一引用符をエスケープする必要があるように見えます。 –