Skip to content

Commit

Permalink
fix(scripts): allow input including koishi-plugin- prefix, fix #606
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Apr 13, 2022
1 parent bd78a60 commit 8a83424
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@koishijs/scripts",
"description": "Workspace Scripts for Koishi",
"version": "1.3.0",
"version": "1.3.1",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"engines": {
Expand Down
14 changes: 10 additions & 4 deletions packages/scripts/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ class Initiator {
}

async init(name: string) {
this.name = name ||= await this.getName()
name ||= await this.getName()
if (name.includes('koishi-plugin-')) {
this.fullname = name
this.name = name.replace('koishi-plugin-', '')
} else {
this.name = name
this.fullname = name.includes('/')
? name.replace('/', '/koishi-plugin-')
: 'koishi-plugin-' + name
}
this.desc = await this.getDesc()
this.fullname = name.includes('/')
? name.replace('/', '/koishi-plugin-')
: 'koishi-plugin-' + name
this.target = resolve(cwd, 'plugins', name)
await this.write()
}
Expand Down
1 change: 1 addition & 0 deletions packages/scripts/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export interface TsConfig {
export function spawnAsync(args: string[]) {
const child = spawn(args[0], args.slice(1), { cwd, stdio: 'pipe' })
return new Promise<number>((resolve) => {
child.stderr.pipe(process.stderr)
child.on('close', resolve)
})
}

0 comments on commit 8a83424

Please sign in to comment.