Skip to content

Commit

Permalink
fix: 新增 项目简介
Browse files Browse the repository at this point in the history
  • Loading branch information
CaoMeiYouRen committed Dec 14, 2021
1 parent 1514164 commit faef295
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type IPackage = Partial<Package>

export interface InitAnswers {
name: string
description: string
author: string
template: string
/**
Expand Down
13 changes: 13 additions & 0 deletions src/plopfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ module.exports = function (plop: NodePlopAPI) {
default: __DEV__ ? 'temp' : '',
filter: (e: string) => e.trim(),
},
{
type: 'input',
name: 'description',
message: '请输入项目简介',
// validate(input: string) {
// return input.trim().length !== 0
// },
transformer(input: string) {
return input?.trim() || ''
},
default: __DEV__ ? '' : '',
filter: (e: string) => e.trim(),
},
{
type: 'input',
name: 'author',
Expand Down
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export async function asyncExec(cmd: string, options?: ExecOptions) {

export async function init(projectPath: string, answers: InitAnswers) {
const loading = ora('正在安装依赖……')
const { name, author, isOpenSource, isRemoveDependabot } = answers
const { name, author, description, isOpenSource, isRemoveDependabot } = answers
try {
await asyncExec('git --version', {
cwd: projectPath,
Expand Down Expand Up @@ -126,6 +126,7 @@ export async function init(projectPath: string, answers: InitAnswers) {
const pkgData: IPackage = {
name,
author,
description,
private: !isOpenSource,
}
const newPkg = Object.assign({}, pkg, pkgData)
Expand Down

0 comments on commit faef295

Please sign in to comment.