UNPKG

@controlplane/cli

Version:

Control Plane Corporation CLI

36 lines 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.detectTarErrorOrWarning = exports.humanReadableSize = void 0; function humanReadableSize(bytes) { if (bytes >= 1e9) { // 1,000,000,000 bytes = 1 GB return { value: (bytes / 1e9).toFixed(2), unit: 'GB' }; } else if (bytes >= 1e6) { // 1,000,000 bytes = 1 MB return { value: (bytes / 1e6).toFixed(2), unit: 'MB' }; } else if (bytes >= 1e3) { // 1,000 bytes = 1 KB return { value: (bytes / 1e3).toFixed(2), unit: 'KB' }; } return { value: bytes.toString(), unit: 'Bytes' }; } exports.humanReadableSize = humanReadableSize; function detectTarErrorOrWarning(data) { // Convert buffer to UTF-8 string const text = data.toString('utf8').trim(); // Check for tar errors (multi-line or single-line) if (/tar:\s*(error|cannot|failed|stat|invalid|not found|exiting)/i.test(text) || /tar:\s*Exiting with failure status due to previous errors/i.test(text)) { return 'error'; } // Check for tar warnings (multi-line or single-line) if (/tar:\s*(warning|skipping|ignoring|deprecated|removing leading `\/')/i.test(text)) { return 'warning'; } // If no match, return null return null; } exports.detectTarErrorOrWarning = detectTarErrorOrWarning; //# sourceMappingURL=helpers.js.map