harvest-overtime
Version:
Track the overtime!
27 lines (26 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.decorateArgs = void 0;
const path = require("path");
function decorateArgs(input, output, rDayHours) {
const inputPath = mkPathAbsolute(input.option, input.default);
const outputPath = mkPathAbsolute(output.option, output.default);
const regularDayHours = mkNumber(rDayHours.option, rDayHours.default);
return {
inputPath,
outputPath,
regularDayHours,
};
}
exports.decorateArgs = decorateArgs;
function mkPathAbsolute(maybeFilePath, defaultPath) {
const filePath = maybeFilePath !== null && maybeFilePath !== void 0 ? maybeFilePath : defaultPath;
return filePath && !path.isAbsolute(filePath)
? path.join(process.cwd(), filePath)
: filePath;
}
function mkNumber(maybeValue, defaultValue) {
const value = maybeValue !== null && maybeValue !== void 0 ? maybeValue : defaultValue;
const result = Number(value);
return isNaN(result) ? Number(defaultValue) : result;
}