Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

builder-util

Package Overview
Dependencies
Maintainers
1
Versions
258
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

builder-util - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

4

out/log.d.ts

@@ -11,3 +11,3 @@ /// <reference types="node" />

export declare type LogLevel = "info" | "warn" | "debug" | "notice" | "error";
export declare const PADDING = 3;
export declare const PADDING = 2;
export declare class Logger {

@@ -25,5 +25,5 @@ protected readonly stream: WritableStream;

private _doLog(message, fields, level);
static createMessage(message: string, fields: Fields | null, level: LogLevel, color: (it: string) => string): string;
static createMessage(message: string, fields: Fields | null, level: LogLevel, color: (it: string) => string, messagePadding?: number): string;
log(message: string): void;
}
export declare const log: Logger;

@@ -24,3 +24,3 @@ "use strict";

}
const PADDING = exports.PADDING = 3;
const PADDING = exports.PADDING = 2;
class Logger {

@@ -64,16 +64,30 @@ constructor(stream) {

this.stream.write(`${" ".repeat(PADDING)}${color(levelIndicator)} `);
this.stream.write(Logger.createMessage(this.messageTransformer(message, level), fields, level, color));
this.stream.write(Logger.createMessage(this.messageTransformer(message, level), fields, level, color, PADDING + 2 /* level indicator and space */));
this.stream.write("\n");
}
static createMessage(message, fields, level, color) {
static createMessage(message, fields, level, color, messagePadding = 0) {
if (fields == null) {
return message;
}
let text = message;
const fieldPadding = " ".repeat(Math.max(0, 16 - message.length));
const fieldPadding = " ".repeat(Math.max(1, 16 - message.length));
text += fieldPadding;
if (fields != null) {
for (const name of Object.keys(fields)) {
let fieldValue = fields[name];
if (fieldValue != null && typeof fieldValue === "string" && fieldValue.includes("\n")) {
fieldValue = ("\n" + fieldValue).replace(/\n/g, `\n${" ".repeat(PADDING)}${fieldPadding}`);
const fieldNames = Object.keys(fields);
let counter = 0;
for (const name of fieldNames) {
let fieldValue = fields[name];
let valuePadding = null;
if (fieldValue != null && typeof fieldValue === "string" && fieldValue.includes("\n")) {
valuePadding = " ".repeat(messagePadding + message.length + fieldPadding.length + 2);
fieldValue = "\n" + valuePadding + fieldValue.replace(/\n/g, `\n${valuePadding}`);
} else if (Array.isArray(fieldValue)) {
fieldValue = JSON.stringify(fieldValue);
}
text += `${color(name)}=${fieldValue}`;
if (++counter !== fieldNames.length) {
if (valuePadding == null) {
text += " ";
} else {
text += "\n" + valuePadding;
}
text += ` ${color(name)}=${Array.isArray(fieldValue) ? JSON.stringify(fieldValue) : fieldValue}`;
}

@@ -80,0 +94,0 @@ }

@@ -271,16 +271,22 @@ "use strict";

function exec(file, args, options, isLogOutIfDebug = true) {
if ((_log || _load_log()).debug.enabled) {
(_log || _load_log()).log.debug({ file, args: args == null ? "" : removePassword(args.join(" ")) }, "executing");
if (options != null && options.env != null) {
const diffEnv = Object.assign({}, options.env);
for (const name of Object.keys(process.env)) {
if (process.env[name] === options.env[name]) {
delete diffEnv[name];
if ((_log || _load_log()).log.isDebugEnabled) {
const logFields = {
file,
args: args == null ? "" : removePassword(args.join(" "))
};
if (options != null) {
if (options.cwd != null) {
logFields.cwd = options.cwd;
}
if (options.env != null) {
const diffEnv = Object.assign({}, options.env);
for (const name of Object.keys(process.env)) {
if (process.env[name] === options.env[name]) {
delete diffEnv[name];
}
}
logFields.env = (0, (_builderUtilRuntime || _load_builderUtilRuntime()).safeStringifyJson)(diffEnv);
}
(0, (_log || _load_log()).debug)(`env: ${(0, (_builderUtilRuntime || _load_builderUtilRuntime()).safeStringifyJson)(diffEnv)}`);
}
if (options != null && options.cwd != null) {
(_log || _load_log()).log.debug(null, `cwd: ${options.cwd}`);
}
(_log || _load_log()).log.debug(logFields, "executing");
}

@@ -290,9 +296,13 @@ return new (_bluebirdLst || _load_bluebirdLst()).default((resolve, reject) => {

if (error == null) {
if (isLogOutIfDebug && (_log || _load_log()).debug.enabled) {
if (stderr.length !== 0) {
(0, (_log || _load_log()).debug)(file.endsWith("wine") ? removeWineSpam(stderr.toString()) : stderr);
if (isLogOutIfDebug && (_log || _load_log()).log.isDebugEnabled) {
const logFields = {
file
};
if (stdout.length > 0) {
logFields.stdout = stdout;
}
if (stdout.length !== 0) {
(0, (_log || _load_log()).debug)(stdout);
if (stderr.length > 0) {
logFields.stderr = file.endsWith("wine") ? removeWineSpam(stderr.toString()) : stderr;
}
(_log || _load_log()).log.debug(logFields, "executed");
}

@@ -333,8 +343,12 @@ resolve(stdout.toString());

// use general debug.enabled to log spawn, because it doesn't produce a lot of output (the only line), but important in any case
if ((_log || _load_log()).debug.enabled) {
if ((_log || _load_log()).log.isDebugEnabled) {
const argsString = args.join(" ");
(_log || _load_log()).log.debug({ command, args: command === "docker" ? argsString : removePassword(argsString) }, "spawning");
const logFields = {
command,
args: command === "docker" ? argsString : removePassword(argsString)
};
if (options != null && options.cwd != null) {
(0, (_log || _load_log()).debug)({ cwd: options.cwd }, "");
logFields.cwd = options.cwd;
}
(_log || _load_log()).log.debug(logFields, "spawning");
}

@@ -387,4 +401,8 @@ try {

childProcess.once(event, code => {
if (code === 0 && (_log || _load_log()).debug.enabled) {
(_log || _load_log()).log.debug({ command: _path.basename(command), pid: childProcess.pid }, "exited with exit code 0");
if ((_log || _load_log()).log.isDebugEnabled) {
(_log || _load_log()).log.debug({
command: _path.basename(command),
code,
pid: childProcess.pid
}, "exited");
}

@@ -391,0 +409,0 @@ if (code === 0) {

{
"name": "builder-util",
"version": "4.0.0",
"version": "4.1.0",
"main": "out/util.js",

@@ -16,3 +16,3 @@ "author": "Vladimir Krivosheev",

"fs-extra-p": "^4.5.0",
"is-ci": "^1.0.10",
"is-ci": "^1.1.0",
"stat-mode": "^0.2.2",

@@ -19,0 +19,0 @@ "bluebird-lst": "^1.0.5",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc