提交 6b26b6dc 编写于 作者: B bryk

Fix go build process to actaully use customizes env variables

上级 148face9
...@@ -66,8 +66,6 @@ gulp.task('backend:prod', ['package-backend-source'], function(doneFn) { ...@@ -66,8 +66,6 @@ gulp.task('backend:prod', ['package-backend-source'], function(doneFn) {
doneFn, { doneFn, {
// Disable cgo package. Required to run on scratch docker image. // Disable cgo package. Required to run on scratch docker image.
CGO_ENABLED: '0', CGO_ENABLED: '0',
// Scratch docker image is linux.
GOOS: 'linux',
}); });
}, },
function(error) { doneFn(error); }); function(error) { doneFn(error); });
......
...@@ -44,9 +44,13 @@ const minGoVersion = '1.5.0'; ...@@ -44,9 +44,13 @@ const minGoVersion = '1.5.0';
* *
* @param {!Array<string>} args - Arguments of the go command. * @param {!Array<string>} args - Arguments of the go command.
* @param {function(?Error=)} doneFn - Callback. * @param {function(?Error=)} doneFn - Callback.
* @param {!Object<string, string>=} [envOverride] optional environment variables overrides map.
*/ */
export default function spawnGoProcess(args, doneFn) { export default function spawnGoProcess(args, doneFn, envOverride) {
checkPrerequisites().then(() => spawnProcess(args)).then(doneFn).fail((error) => doneFn(error)); checkPrerequisites()
.then(() => spawnProcess(args, envOverride))
.then(doneFn)
.fail((error) => doneFn(error));
} }
/** /**
...@@ -146,12 +150,14 @@ function checkGodep() { ...@@ -146,12 +150,14 @@ function checkGodep() {
* Promises an error if the go command process fails. * Promises an error if the go command process fails.
* *
* @param {!Array<string>} args - Arguments of the go command. * @param {!Array<string>} args - Arguments of the go command.
* @param {!Object<string, string>=} [envOverride] optional environment variables overrides map.
* @return {Q.Promise} A promise object. * @return {Q.Promise} A promise object.
*/ */
function spawnProcess(args) { function spawnProcess(args, envOverride) {
let deferred = q.defer(); let deferred = q.defer();
let envLocal = lodash.merge(env, envOverride);
let goTask = child.spawn('godep', ['go'].concat(args), { let goTask = child.spawn('godep', ['go'].concat(args), {
env: env, env: envLocal,
stdio: 'inherit', stdio: 'inherit',
}); });
// Call Gulp callback on task exit. This has to be done to make Gulp dependency management // Call Gulp callback on task exit. This has to be done to make Gulp dependency management
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册