mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-20 09:26:42 +00:00
Enable debug-mode "long stack traces" for Bluebird promises (async code)
Change-type: patch Signed-off-by: Paulo Castro <paulo@balena.io>
This commit is contained in:
parent
09f04be77d
commit
2222a90884
@ -90,21 +90,34 @@ function setupBalenaSdkSharedOptions() {
|
||||
});
|
||||
}
|
||||
|
||||
export function globalInit() {
|
||||
setupRaven();
|
||||
checkNodeVersion();
|
||||
setupGlobalHttpProxy();
|
||||
setupBalenaSdkSharedOptions();
|
||||
let BluebirdConfigured = false;
|
||||
|
||||
// Assign bluebird as the global promise library.
|
||||
// stream-to-promise will produce native promises if not for this module,
|
||||
// which is likely to lead to errors as much of the CLI coffeescript code
|
||||
// expects bluebird promises.
|
||||
// The registration is only run if it hasn't already happened (for example
|
||||
// in a test case).
|
||||
/**
|
||||
* Configure Bluebird and assign it as the global promise library.
|
||||
* Modules like `stream-to-promise` will otherwise produce native promises,
|
||||
* which leads to errors as much of the CLI CoffeeScript code expects Bluebird
|
||||
* promises.
|
||||
*/
|
||||
export function configureBluebird() {
|
||||
if (BluebirdConfigured) {
|
||||
return;
|
||||
}
|
||||
BluebirdConfigured = true;
|
||||
const Bluebird = require('bluebird');
|
||||
Bluebird.config({
|
||||
longStackTraces: process.env.DEBUG ? true : false,
|
||||
});
|
||||
if (!(global as any)['@@any-promise/REGISTRATION']) {
|
||||
require('any-promise/register/bluebird');
|
||||
}
|
||||
}
|
||||
|
||||
export function globalInit() {
|
||||
setupRaven();
|
||||
checkNodeVersion();
|
||||
configureBluebird();
|
||||
setupGlobalHttpProxy();
|
||||
setupBalenaSdkSharedOptions();
|
||||
|
||||
// check for CLI updates once a day
|
||||
require('./utils/update').notify();
|
||||
|
@ -20,6 +20,9 @@ import * as nock from 'nock';
|
||||
import * as path from 'path';
|
||||
|
||||
import * as balenaCLI from '../build/app';
|
||||
import { configureBluebird } from '../build/app-common';
|
||||
|
||||
configureBluebird();
|
||||
|
||||
export const runCommand = async (cmd: string) => {
|
||||
const preArgs = [process.argv[0], path.join(process.cwd(), 'bin', 'balena')];
|
||||
|
Loading…
x
Reference in New Issue
Block a user