markmap-cli
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -14,4 +14,5 @@ #!/usr/bin/env node | ||
.action((input, cmd) => { | ||
return createMarkmap(input, { | ||
return createMarkmap({ | ||
open: cmd.open, | ||
input, | ||
output: cmd.output, | ||
@@ -18,0 +19,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
/*! markmap-cli v0.1.1 | MIT License */ | ||
/*! markmap-cli v0.2.0 | MIT License */ | ||
'use strict'; | ||
@@ -14,12 +14,20 @@ | ||
let template; | ||
async function createMarkmap(input, options = {}) { | ||
const text = await fs.promises.readFile(input, 'utf8'); | ||
async function createMarkmap(options = {}) { | ||
const { | ||
input, | ||
open: openFile = true | ||
} = options; | ||
let { | ||
content, | ||
output | ||
} = options; | ||
if (!output) output = `${input.replace(/\.\w*$/, '')}.html`; | ||
if (input) { | ||
content = await fs.promises.readFile(input, 'utf8'); | ||
} | ||
if (!output) { | ||
output = input ? `${input.replace(/\.\w*$/, '')}.html` : 'markmap.html'; | ||
} | ||
if (!template) { | ||
@@ -29,3 +37,3 @@ template = await fs.promises.readFile(`${__dirname}/../templates/markmap.html`, 'utf8'); | ||
const data = transform(parse(text)); | ||
const data = transform(parse(content || '')); | ||
const html = template.replace('{/* data */}', JSON.stringify(data)); | ||
@@ -32,0 +40,0 @@ fs.promises.writeFile(output, html, 'utf8'); |
{ | ||
"name": "markmap-cli", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Visualize your Markdown as mindmaps with Markmap", | ||
@@ -5,0 +5,0 @@ "author": "Gerald <i@gerald.top>", |
export interface ICreateOptions { | ||
open?: boolean; | ||
content?: string; | ||
input?: string; | ||
output?: string; | ||
} | ||
export declare function createMarkmap(input: string, options?: ICreateOptions): Promise<void>; | ||
export declare function createMarkmap(options?: ICreateOptions): Promise<void>; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5912
58