UNPKG

interactive-cli-leetcode-solutions

Version:
30 lines (29 loc) 1.22 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const child_process_1 = require("child_process"); const fs_1 = require("fs"); const buildAssetsPath_js_1 = __importDefault(require("./utils/buildAssetsPath.js")); const types_js_1 = require("./types.js"); const showProblem = (problem) => { try { const codePath = (0, buildAssetsPath_js_1.default)(`code/${problem.toLowerCase().replaceAll(' ', '-')}.cpp`); switch (process.platform) { case types_js_1.Platform.Windows: (0, child_process_1.execSync)(`more ${codePath}`, { stdio: 'inherit' }); break; case types_js_1.Platform.Mac: case types_js_1.Platform.Linux: (0, child_process_1.execSync)(`less ${codePath}`, { stdio: 'inherit' }); break; default: console.log((0, fs_1.readFileSync)(codePath, 'utf8')); } } catch (error) { console.log('There was an error with showing the problem', error); } }; exports.default = showProblem;