mdts 0.3.2 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/mdts CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import '../dist/index.js';
3
+ require('../dist/index.js');
package/dist/cli.js CHANGED
@@ -1,21 +1,35 @@
1
- import { serve } from './server/server.js';
2
- import open from 'open';
3
- import { Command } from 'commander';
4
- import { existsSync } from 'fs';
5
- import path from 'path';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CLI = void 0;
7
+ const commander_1 = require("commander");
8
+ const fs_1 = require("fs");
9
+ const path_1 = __importDefault(require("path"));
10
+ const server_1 = require("./server/server");
6
11
  const DEFAULT_PORT = 8521;
7
12
  const DEFAULT_DIRECTORY = '.';
8
- export const cli = () => {
9
- const program = new Command();
10
- program
11
- .option('-p, --port <port>', 'Port to serve on', String(DEFAULT_PORT))
12
- .argument('[directory]', 'Directory to serve', DEFAULT_DIRECTORY)
13
- .action((directory, options) => {
14
- const port = parseInt(options.port, 10);
15
- serve(directory, port);
16
- const readmePath = path.join(directory, 'README.md');
17
- const initialPath = existsSync(readmePath) ? '/README.md' : '';
18
- open(`http://localhost:${port}${initialPath}`);
19
- });
20
- program.parse(process.argv);
21
- };
13
+ class CLI {
14
+ run() {
15
+ return this.requireOpen()
16
+ .then((open) => {
17
+ const program = new commander_1.Command();
18
+ program
19
+ .option('-p, --port <port>', 'Port to serve on', String(DEFAULT_PORT))
20
+ .argument('[directory]', 'Directory to serve', DEFAULT_DIRECTORY)
21
+ .action((directory, options) => {
22
+ const port = parseInt(options.port, 10);
23
+ (0, server_1.serve)(directory, port);
24
+ const readmePath = path_1.default.join(directory, 'README.md');
25
+ const initialPath = (0, fs_1.existsSync)(readmePath) ? '/README.md' : '';
26
+ open(`http://localhost:${port}${initialPath}`);
27
+ });
28
+ program.parse(process.argv);
29
+ });
30
+ }
31
+ requireOpen() {
32
+ return import('open').then((module) => module.default);
33
+ }
34
+ }
35
+ exports.CLI = CLI;