UNPKG

packdir-cli

Version:
51 lines 1.93 kB
"use strict"; /** * Create an EPUB. */ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const promises_1 = require("fs/promises"); const core_1 = require("@oclif/core"); const packDocument_1 = require("../packDocument"); const lib_1 = tslib_1.__importDefault(require("../lib")); class Create extends core_1.Command { async run() { var _a; console.log('操作系统:', process.platform); //chokdir.watch('.').on('all', (event, path) => { // console.log('event: ', event) // console.log('path: ', path) //}) return; const { args, flags } = await this.parse(Create); const name = (_a = flags.name) !== null && _a !== void 0 ? _a : 'world'; this.log(`hello ${name} from /mnt/d/Henry/packdir/pd/src/commands/gen.ts`); if (args.file && flags.force) { this.log(`you input --force and --file: ${args.file}`); } // Test epub. //const metadata = { // title: "custome title" //} //const epub2 = new Packdocument(metadata) //epub2.saveAsEpub() // Generate from markdown files in current path. const [options, mdcontent] = await packDocument_1.Packdocument.generateFromPath(); const contentmd = mdcontent; const content = await (0, lib_1.default)(options, contentmd); await (0, promises_1.writeFile)(`${options.title}.epub`, Buffer.from(content)); } } exports.default = Create; Create.description = 'Create an EPUB book.'; Create.examples = [ '<%= config.bin %> <%= command.id %>', ]; Create.flags = { // flag with a value (-n, --name=VALUE) name: core_1.Flags.string({ char: 'n', description: 'name to print' }), // flag with no value (-f, --force) force: core_1.Flags.boolean({ char: 'f' }), }; Create.args = [{ name: 'file' }]; //# sourceMappingURL=gen.js.map