-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.ts
31 lines (26 loc) · 928 Bytes
/
index.ts
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
31
import path from 'node:path';
import Generator from 'yeoman-generator';
import { AssetSrc } from '../../helpers/asset-src.js';
import { getTemplatePath } from '../utils.js';
export default class extends Generator {
constructor(args: string|string[], opts: Record<string, any>) {
super(args, opts);
this.argument('asset_path', { type: String, required: true });
this.option('new', {
type: Boolean
});
this.sourceRoot(getTemplatePath('registry'));
}
paths(): void {
this.destinationRoot(path.join(this.options.asset_path, 'asset'));
}
async default(): Promise<void> {
const asset = new AssetSrc(this.options.asset_path);
const registry = await asset.generateRegistry();
this.fs.copyTpl(
this.templatePath('index.ejs'),
this.destinationPath('index.js'),
{ registry }
);
}
}