51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.printCompositions = void 0;
|
|
const log_1 = require("./log");
|
|
const parsed_cli_1 = require("./parsed-cli");
|
|
const max = (arr) => {
|
|
if (arr.length === 0) {
|
|
throw new Error('Array of 0 length');
|
|
}
|
|
let biggest = arr[0];
|
|
for (let i = 0; i < arr.length; i++) {
|
|
const elem = arr[i];
|
|
if (elem > biggest) {
|
|
biggest = elem;
|
|
}
|
|
}
|
|
return biggest;
|
|
};
|
|
const printCompositions = (compositions, logLevel) => {
|
|
if (!(0, parsed_cli_1.quietFlagProvided)()) {
|
|
log_1.Log.info({ indent: false, logLevel });
|
|
log_1.Log.info({ indent: false, logLevel }, 'The following compositions are available:');
|
|
log_1.Log.info({ indent: false, logLevel });
|
|
}
|
|
if ((0, parsed_cli_1.quietFlagProvided)()) {
|
|
log_1.Log.info({ indent: false, logLevel }, compositions.map((c) => c.id).join(' '));
|
|
return;
|
|
}
|
|
const firstColumnLength = max(compositions.map(({ id }) => id.length)) + 4;
|
|
const secondColumnLength = 8;
|
|
const thirdColumnLength = 15;
|
|
log_1.Log.info({ indent: false, logLevel }, compositions
|
|
.map((comp) => {
|
|
const isStill = comp.durationInFrames === 1;
|
|
const dimensions = `${comp.width}x${comp.height}`;
|
|
const fps = isStill ? '' : comp.fps.toString();
|
|
const durationInSeconds = (comp.durationInFrames / comp.fps).toFixed(2);
|
|
const formattedDuration = isStill
|
|
? 'Still'
|
|
: `${comp.durationInFrames} (${durationInSeconds} sec)`;
|
|
return [
|
|
comp.id.padEnd(firstColumnLength, ' '),
|
|
fps.padEnd(secondColumnLength, ' '),
|
|
dimensions.padEnd(thirdColumnLength, ' '),
|
|
formattedDuration,
|
|
].join('');
|
|
})
|
|
.join('\n'));
|
|
};
|
|
exports.printCompositions = printCompositions;
|