mangakonekuto
Version:
Your CLI for reading manga from the terminal
75 lines (74 loc) • 3.45 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_extra_1 = __importDefault(require("fs-extra"));
const os_1 = __importDefault(require("os"));
const path_1 = __importDefault(require("path"));
const chalk_1 = __importDefault(require("chalk"));
const child_process_1 = require("child_process");
const Launcher_1 = require("./utils/Launcher");
const SettingsConfig_1 = __importDefault(require("./utils/SettingsConfig"));
SettingsConfig_1.default.set("foo", "bar");
const dataFolder = path_1.default.join(os_1.default.homedir(), '.config', 'MangaKonekuto');
fs_extra_1.default.ensureDirSync(dataFolder);
console.log(`✅ Ensured settings directory at: ${dataFolder}`);
function findLocalChrome() {
const localPath = path_1.default.resolve(__dirname, '../local-chromium');
if (!fs_extra_1.default.existsSync(localPath))
return null;
const dirs = fs_extra_1.default.readdirSync(localPath);
for (const dir of dirs) {
const chromePath = path_1.default.join(localPath, dir, 'chrome-win', 'chrome.exe');
if (fs_extra_1.default.existsSync(chromePath)) {
return chromePath;
}
}
return null;
}
function findSystemChrome() {
try {
const whereOutput = (0, child_process_1.execSync)('where chrome', { stdio: ['pipe', 'pipe', 'ignore'] }).toString();
const paths = whereOutput.split(/\r?\n/).filter(Boolean);
return paths[0] || null;
}
catch (_a) {
return null;
}
}
function run() {
return __awaiter(this, void 0, void 0, function* () {
console.log(chalk_1.default.blue("🔍 Checking for local Chrome..."));
let chromePath = findLocalChrome();
if (chromePath) {
console.log(chalk_1.default.green(`✅ Found local Chrome at: ${chromePath}`));
}
else {
console.log(chalk_1.default.yellow("⚠️ No local Chrome found in `local-chromium`. Trying to find system Chrome..."));
chromePath = findSystemChrome();
if (chromePath) {
console.log(chalk_1.default.green(`✅ Found system Chrome at: ${chromePath}`));
}
else {
console.log(chalk_1.default.red("❌ No Chrome executable found on your system."));
console.log(chalk_1.default.yellow("Please install Google Chrome or place Chromium in the `local-chromium` folder."));
process.exit(1);
}
}
process.env.CHROME_PATH = chromePath;
const cli = new Launcher_1.MangaCLI();
yield cli.run();
});
}
run();