"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); require("dotenv/config"); const log_1 = require("./log"); const promises_1 = require("fs/promises"); const path_1 = require("path"); const shell_1 = require("./shell"); class Generate { constructor() { this.inbox = typeof process.env.INBOX !== 'undefined' ? process.env.INBOX : '~/Photos/toprocess'; this.log = (0, log_1.createLog)('generate'); this.log.info(`Generating site: ${new Date()}`); this.generate(); } async generate() { await this.checkInbox(); } async checkInbox() { let inbox; let images; try { inbox = await (0, promises_1.realpath)(this.inbox); } catch (err) { this.log.error(err); return; } try { images = await (0, promises_1.readdir)(inbox); } catch (err) { this.log.error(err); return; } images = images.filter(el => { if (el.toLowerCase().indexOf('.jpg') !== -1 || el.toLowerCase().indexOf('.jpeg') !== -1 || el.toLowerCase().indexOf('.tif') !== -1 || el.toLowerCase().indexOf('.tiff') !== -1) { return true; } return false; }); if (images.length === 0) { this.log.info(`No new images found`); return; } images = images.map(el => (0, path_1.join)(inbox, el)); console.dir(images); } async img(file) { const cmd = ['bash', 'scripts/img.sh', file]; const shell = new shell_1.Shell(cmd); try { await shell.execute(); } catch (err) { this.log.error(err); return; } this.log.info(`Processed image file for ${file}`); } } new Generate(); //# sourceMappingURL=generate.js.map