-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd
More file actions
executable file
·30 lines (26 loc) · 809 Bytes
/
add
File metadata and controls
executable file
·30 lines (26 loc) · 809 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
26
27
28
29
30
#!/usr/bin/env node
const fs = require("fs")
const path = require("path")
const args = process.argv.slice(2);
const title = args[0]
const file = path.join(__dirname, 'src/templates', `${args[0]}.js`)
const nouser = args[1] === "--nouser" || false
const triggers = nouser ? ['PRE_REGISTER'] : ['POST_REGISTER', 'POST_AUTHENTICATION']
const arguments = nouser ? ['context', 'callback'] : ['user', 'context', 'callback']
const returnArgs = nouser ? ['null', 'context'] : ['null', 'user', 'context']
const data = `
/**
* @title_zh ${title}
* @tile_en ${title}
* @type ${triggers.join(',')}
* @async false
* @category
* @category_en
* @overview_zh ${title}
* @overview_en ${title}
*/
async function pipe(${arguments.join(', ')}) {
callback(${returnArgs.join(', ')})
}
`
fs.writeFileSync(file, data)