@cabloy/cli-set-api
Version:
cabloy cli-set-api
33 lines • 1.17 kB
JavaScript
import { BeanCliBase } from '@cabloy/cli';
import fs from 'fs';
import path from 'path';
import { __ThisSetName__ } from '../this.js';
export class CliCreateSuite extends BeanCliBase {
async execute() {
const { argv } = this.context;
// super
await super.execute();
// suite name/info
const suiteName = argv.name;
argv.suiteInfo = this.helper.parseSuiteInfo(suiteName);
// check if exists
const _suite = this.helper.findSuite(suiteName);
if (_suite) {
throw new Error(`suite exists: ${suiteName}`);
}
// target dir
let targetDir = path.join(argv.projectPath, 'src/suite', suiteName);
if (fs.existsSync(targetDir)) {
throw new Error(`suite exists: ${suiteName}`);
}
targetDir = await this.helper.ensureDir(targetDir);
// templateDir
const templateDir = this.template.resolveTemplatePath({
setName: __ThisSetName__,
path: 'create/suite',
});
// render
await this.template.renderDir({ targetDir, templateDir });
}
}
//# sourceMappingURL=cli.create.suite.js.map