Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
nmsn committed Jun 28, 2023
1 parent 8559b01 commit 8c487b1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
lib/
esm/
tsconfig.tsbuildinfo
tsconfig.tsbuildinfo
release-toolbox.json
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { md } from './md.js';

export { createMd, insertMd } from './utils.js';
2 changes: 1 addition & 1 deletion src/md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type TableParamsType = { type: 'table'; params: [header: string[], content: stri

type DataType = (HeadingParamsType | BlockquoteParamsType | LinkParamsType | TableParamsType)[];

export const write = (data: DataType) => {
export const md = (data: DataType) => {
const headingMap = Array(5)
.fill(undefined)
.map((_, index) => index + 1)
Expand Down
8 changes: 4 additions & 4 deletions src/test.js → src/test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { writeFileToLine } from './utils.js';
import { write } from './md.js';
import { insertMd } from './utils.js';
import { md } from './md.js';

writeFileToLine(
insertMd(
'TEST.md',
write([
md([
{ type: 'h1', params: '123' },
{ type: 'h2', params: '123' },
{ type: 'h3', params: '123' },
Expand Down
5 changes: 2 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import fs from 'fs';
import path from 'path';

import { LF } from './md.js';

//往固定的行写入数据
export const writeFileToLine = (fileName: string, content: string, line = 0) => {
export const insertMd = (fileName: string, content: string, line = 0) => {
const _path = path.resolve('./', fileName);

// 计算行
Expand All @@ -18,7 +17,7 @@ export const writeFileToLine = (fileName: string, content: string, line = 0) =>
fs.writeFileSync(_path, outputMd);
};

export const createNewFile = (fileName: string, content: string) => {
export const createMd = (fileName: string, content: string) => {
const _path = path.resolve('./', fileName);
fs.writeFileSync(_path, content);
};

0 comments on commit 8c487b1

Please sign in to comment.