move tools dir into src
This commit is contained in:
parent
f5bea67515
commit
270df5c5b0
21 changed files with 0 additions and 210 deletions
30
packages/backend/src/tools/add-emoji.ts
Normal file
30
packages/backend/src/tools/add-emoji.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { Emojis } from '@/models/index';
|
||||
import { genId } from '@/misc/gen-id';
|
||||
|
||||
async function main(name: string, url: string, alias?: string): Promise<any> {
|
||||
const aliases = alias != null ? [ alias ] : [];
|
||||
|
||||
await Emojis.save({
|
||||
id: genId(),
|
||||
host: null,
|
||||
name,
|
||||
url,
|
||||
aliases,
|
||||
updatedAt: new Date()
|
||||
});
|
||||
}
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const name = args[0];
|
||||
const url = args[1];
|
||||
|
||||
if (!name) throw new Error('require name');
|
||||
if (!url) throw new Error('require url');
|
||||
|
||||
main(name, url).then(() => {
|
||||
console.log('success');
|
||||
process.exit(0);
|
||||
}).catch(e => {
|
||||
console.warn(e);
|
||||
process.exit(1);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue