mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-21 09:51:58 +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() {
|
let BluebirdConfigured = false;
|
||||||
setupRaven();
|
|
||||||
checkNodeVersion();
|
|
||||||
setupGlobalHttpProxy();
|
|
||||||
setupBalenaSdkSharedOptions();
|
|
||||||
|
|
||||||
// Assign bluebird as the global promise library.
|
/**
|
||||||
// stream-to-promise will produce native promises if not for this module,
|
* Configure Bluebird and assign it as the global promise library.
|
||||||
// which is likely to lead to errors as much of the CLI coffeescript code
|
* Modules like `stream-to-promise` will otherwise produce native promises,
|
||||||
// expects bluebird promises.
|
* which leads to errors as much of the CLI CoffeeScript code expects Bluebird
|
||||||
// The registration is only run if it hasn't already happened (for example
|
* promises.
|
||||||
// in a test case).
|
*/
|
||||||
|
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']) {
|
if (!(global as any)['@@any-promise/REGISTRATION']) {
|
||||||
require('any-promise/register/bluebird');
|
require('any-promise/register/bluebird');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function globalInit() {
|
||||||
|
setupRaven();
|
||||||
|
checkNodeVersion();
|
||||||
|
configureBluebird();
|
||||||
|
setupGlobalHttpProxy();
|
||||||
|
setupBalenaSdkSharedOptions();
|
||||||
|
|
||||||
// check for CLI updates once a day
|
// check for CLI updates once a day
|
||||||
require('./utils/update').notify();
|
require('./utils/update').notify();
|
||||||
|
@ -20,6 +20,9 @@ import * as nock from 'nock';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
import * as balenaCLI from '../build/app';
|
import * as balenaCLI from '../build/app';
|
||||||
|
import { configureBluebird } from '../build/app-common';
|
||||||
|
|
||||||
|
configureBluebird();
|
||||||
|
|
||||||
export const runCommand = async (cmd: string) => {
|
export const runCommand = async (cmd: string) => {
|
||||||
const preArgs = [process.argv[0], path.join(process.cwd(), 'bin', 'balena')];
|
const preArgs = [process.argv[0], path.join(process.cwd(), 'bin', 'balena')];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user