mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-21 09:51:58 +00:00
Send all debug output to stderr
Change-type: patch Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
32c588db55
commit
7a865b2e15
@ -22,6 +22,7 @@ import { execFile, spawn } from 'child_process';
|
|||||||
import { stripIndent } from 'common-tags';
|
import { stripIndent } from 'common-tags';
|
||||||
import * as filehound from 'filehound';
|
import * as filehound from 'filehound';
|
||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
|
import * as _ from 'lodash';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { exec as execPkg } from 'pkg';
|
import { exec as execPkg } from 'pkg';
|
||||||
import * as rimraf from 'rimraf';
|
import * as rimraf from 'rimraf';
|
||||||
@ -348,7 +349,18 @@ async function getSubprocessStdout(
|
|||||||
child.stderr.on('data', (data: Buffer) => {
|
child.stderr.on('data', (data: Buffer) => {
|
||||||
try {
|
try {
|
||||||
const stderr = data.toString();
|
const stderr = data.toString();
|
||||||
reject(new Error(`"${execPath}": non-empty stderr "${stderr}"`));
|
|
||||||
|
// ignore any debug lines, but ensure that we parse
|
||||||
|
// every line provided to the stderr stream
|
||||||
|
const lines = _.filter(
|
||||||
|
stderr.trim().split(/\r?\n/),
|
||||||
|
line => !line.startsWith('[debug]'),
|
||||||
|
);
|
||||||
|
if (lines.length > 0) {
|
||||||
|
reject(
|
||||||
|
new Error(`"${execPath}": non-empty stderr "${lines.join('\n')}"`),
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ export const push: CommandDefinition<
|
|||||||
|
|
||||||
const source = options.source || '.';
|
const source = options.source || '.';
|
||||||
if (process.env.DEBUG) {
|
if (process.env.DEBUG) {
|
||||||
console.log(`[debug] Using ${source} as build source`);
|
console.error(`[debug] Using ${source} as build source`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const dockerfilePath = validateSpecifiedDockerfile(
|
const dockerfilePath = validateSpecifiedDockerfile(
|
||||||
|
@ -63,8 +63,10 @@ class Logger {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_.forEach(this.streams, function(stream, key) {
|
_.forEach(this.streams, function(stream, key) {
|
||||||
if (key !== 'debug' || process.env.DEBUG) {
|
if (key !== 'debug') {
|
||||||
stream.pipe(process.stdout);
|
stream.pipe(process.stdout);
|
||||||
|
} else if (process.env.DEBUG) {
|
||||||
|
stream.pipe(process.stderr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ function getBuilderMessageHandler(
|
|||||||
): (obj: BuilderMessage) => void {
|
): (obj: BuilderMessage) => void {
|
||||||
return (obj: BuilderMessage) => {
|
return (obj: BuilderMessage) => {
|
||||||
if (DEBUG_MODE) {
|
if (DEBUG_MODE) {
|
||||||
console.log(`[debug] handling message: ${JSON.stringify(obj)}`);
|
console.error(`[debug] handling message: ${JSON.stringify(obj)}`);
|
||||||
}
|
}
|
||||||
if (obj.type != null && obj.type === 'metadata') {
|
if (obj.type != null && obj.type === 'metadata') {
|
||||||
return handleBuilderMetadata(obj, build);
|
return handleBuilderMetadata(obj, build);
|
||||||
@ -318,7 +318,7 @@ function createRemoteBuildRequest(
|
|||||||
): request.Request {
|
): request.Request {
|
||||||
const zlib = require('zlib');
|
const zlib = require('zlib');
|
||||||
if (DEBUG_MODE) {
|
if (DEBUG_MODE) {
|
||||||
console.log(`[debug] Connecting to builder at ${builderUrl}`);
|
console.error(`[debug] Connecting to builder at ${builderUrl}`);
|
||||||
}
|
}
|
||||||
return request
|
return request
|
||||||
.post({
|
.post({
|
||||||
@ -331,7 +331,7 @@ function createRemoteBuildRequest(
|
|||||||
.once('response', (response: request.RequestResponse) => {
|
.once('response', (response: request.RequestResponse) => {
|
||||||
if (response.statusCode >= 100 && response.statusCode < 400) {
|
if (response.statusCode >= 100 && response.statusCode < 400) {
|
||||||
if (DEBUG_MODE) {
|
if (DEBUG_MODE) {
|
||||||
console.log(
|
console.error(
|
||||||
`[debug] received HTTP ${response.statusCode} ${
|
`[debug] received HTTP ${response.statusCode} ${
|
||||||
response.statusMessage
|
response.statusMessage
|
||||||
}`,
|
}`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user