myt/myt-init.js

26 lines
656 B
JavaScript
Raw Permalink Normal View History

2020-12-02 07:35:26 +00:00
2022-12-21 13:17:50 +00:00
const Myt = require('./myt');
const Command = require('./lib/command');
2020-12-02 07:35:26 +00:00
const fs = require('fs-extra');
class Init extends Command {
static usage = {
description: 'Initialize an empty workspace'
};
2022-12-21 13:17:50 +00:00
async run(myt, opts) {
2020-12-02 07:35:26 +00:00
const templateDir = `${__dirname}/template`;
const templates = await fs.readdir(templateDir);
for (let template of templates) {
2022-12-21 13:17:50 +00:00
const dst = `${opts.mytDir}/${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)
2022-12-21 13:17:50 +00:00
new Myt().run(Init);