Skip to content

Commit 1b8324d

Browse files
Hedwig-Fangwh131462
authored andcommittedFeb 5, 2024
feat: 新增填充markdown功能
1 parent 4593058 commit 1b8324d

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed
 

‎common/utils/createMarkdown.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
4+
/**
5+
* 创建markdown
6+
* @param {*} description
7+
* @param {*} questionPath
8+
*/
9+
function createMarkdown(description, questionPath) {
10+
const dir = path.dirname(questionPath);
11+
const descriptionPath = path.join(dir, 'description.md');
12+
fs.writeFileSync(descriptionPath, description);
13+
}
14+
export default createMarkdown;

‎common/utils/fulfillQuestion.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import {removeDomTags} from "./removeDomTags.js";
2-
import fs from "fs";
3-
import {getTestCase} from "./getTestCase.js";
4-
import {getQuestionUrl} from "./getQuestionUrl.js";
1+
import fs from 'fs';
2+
import { removeDomTags } from './removeDomTags.js';
3+
import { getTestCase } from './getTestCase.js';
4+
import { getQuestionUrl } from './getQuestionUrl.js';
5+
import createMarkdown from './createMarkdown.js';
56
/**
67
* @typedef {Object} Question
78
* @property {string} title
@@ -38,6 +39,7 @@ export const fulfillQuestion = (questionPath, question) => {
3839
if (err) throw err;
3940
// 修改文件内容
4041
const newData = generateTemplateContent(data, question);
42+
createMarkdown(question.detail, questionPath);
4143
fs.writeFile(questionPath, newData, (err) => {
4244
if (err) throw err;
4345
console.log(`[fulfillQuestion]题目[${question.id}][${question.title}]已完成填充.`);

0 commit comments

Comments
 (0)