2020-12-02 07:35:26 +00:00
|
|
|
|
2020-12-04 16:30:26 +00:00
|
|
|
const MyVC = require('./myvc');
|
2022-12-21 12:34:17 +00:00
|
|
|
const Command = require('./lib/command');
|
2020-12-02 07:35:26 +00:00
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
2022-12-21 12:34:17 +00:00
|
|
|
class Init extends Command {
|
|
|
|
static usage = {
|
|
|
|
description: 'Initialize an empty workspace'
|
|
|
|
};
|
2021-10-25 13:38:07 +00:00
|
|
|
|
2020-12-02 07:35:26 +00:00
|
|
|
async run(myvc, opts) {
|
|
|
|
const templateDir = `${__dirname}/template`;
|
|
|
|
const templates = await fs.readdir(templateDir);
|
|
|
|
for (let template of templates) {
|
2021-10-25 13:38:07 +00:00
|
|
|
const dst = `${opts.myvcDir}/${template}`;
|
2020-12-02 07:35:26 +00:00
|
|
|
if (!await fs.pathExists(dst))
|
|
|
|
await fs.copy(`${templateDir}/${template}`, dst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Init;
|
|
|
|
|
|
|
|
if (require.main === module)
|
|
|
|
new MyVC().run(Init);
|