Skip to content

Commit

Permalink
fix(jekyll-md): 方法引用问题
Browse files Browse the repository at this point in the history
  • Loading branch information
StreakingMan committed Jul 27, 2022
1 parent 9cfdb3e commit 507836e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 4 additions & 0 deletions actions/jekyll-md.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const inquirer = require('inquirer');
const { fileGenerator } = require('../utils/file-generator');
const { jekyllMarkdownName } = require('../utils/jekyllMarkdownName');
const { execSync } = require('child_process');
const jekyllMD = async (title, category, tags) => {
if (!(title && category && tags)) {
const { inputTitle, inputCategory, inputTags } = await inquirer.prompt([
Expand Down Expand Up @@ -33,6 +35,8 @@ const jekyllMD = async (title, category, tags) => {
option: { title, category, tags },
});

execSync(`git add ${jekyllMarkdownName(title)}`);

console.log(`📚 markdown文件生成完毕`);
};

Expand Down
9 changes: 1 addition & 8 deletions utils/file-generator.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
const { version } = require('../package.json');
const { execSync } = require('child_process');
const { jekyllMarkdownName } = require('./jekyllMarkdownName');
const fs = require('fs');
const fse = require('fs-extra');
const path = require('path');
const ejs = require('ejs');

const jekyllMarkdownName = (title) => {
const now = new Date();
const year = now.getFullYear().toString();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const date = now.getDate().toString().padStart(2, '0');
return `${year}-${month}-${date}-${title.toLowerCase()}.md`;
};

const generatorTemplateFileMap = {
commitlint: '.commitlintrc.js',
editor: '.editorconfig',
Expand Down
11 changes: 11 additions & 0 deletions utils/jekyllMarkdownName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const jekyllMarkdownName = (title) => {
const now = new Date();
const year = now.getFullYear().toString();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const date = now.getDate().toString().padStart(2, '0');
return `${year}-${month}-${date}-${title.toLowerCase()}.md`;
};

module.exports = {
jekyllMarkdownName,
};

0 comments on commit 507836e

Please sign in to comment.