@controlplane/cli
Version:
Control Plane Corporation CLI
30 lines • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeRemoteBuildProgress = makeRemoteBuildProgress;
exports.formatElapsed = formatElapsed;
const plain_1 = require("./plain");
const tty_1 = require("./tty");
// ANCHOR - Exported Functions
/**
* Builds the renderer for this session: a terminal renderer with an upload progress
* bar on a TTY, append-only lines otherwise.
*
* @param {RemoteBuildProgressEnv} env - The output sinks and toggles.
* @returns {RemoteBuildRenderer} The renderer.
*/
function makeRemoteBuildProgress(env) {
return env.isTty ? new tty_1.TtyProgress(env) : new plain_1.PlainProgress(env);
}
/**
* Formats elapsed milliseconds as a compact clock, e.g. "1m42s".
*
* @param {number} millis - The elapsed milliseconds.
* @returns {string} The compact elapsed form.
*/
function formatElapsed(millis) {
const totalSeconds = Math.floor(millis / 1000);
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;
return minutes > 0 ? `${minutes}m${String(seconds).padStart(2, '0')}s` : `${seconds}s`;
}
//# sourceMappingURL=renderer.js.map