-
-
Notifications
You must be signed in to change notification settings - Fork 784
Expand file tree
/
Copy pathcomplete.ts
More file actions
25 lines (23 loc) · 737 Bytes
/
complete.ts
File metadata and controls
25 lines (23 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { Context } from './types'
/**
* Fallback complete hook
*/
export const fallback = async (ctx: Context): Promise<void> => {
console.log(`Created a new project in \`${ctx.project}\` by the \`${ctx.template}\` template.\n`)
ctx.files.map(i => i.path).sort((a, b) => a > b ? +1 : -1).forEach(i => console.log('- ' + i))
console.log('\nHappy hacking :)')
}
/**
* Apply template complete hook.
*/
export default async (ctx: Context): Promise<void> => {
if (ctx.config.complete == null) {
return await fallback(ctx)
}
if (typeof ctx.config.complete === 'string') {
return console.log(ctx.config.complete)
}
const result = await ctx.config.complete(ctx)
if (result == null) return
console.log(result)
}