aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/index.ts b/src/index.ts
new file mode 100644
index 0000000..2a2834b
--- /dev/null
+++ b/src/index.ts
@@ -0,0 +1,26 @@
+#!/usr/bin/env node
+
+import * as fs from 'fs-extra';
+import * as program from 'commander';
+import tag from './tag/tag';
+import scss from './tag/scss';
+import index from './tag/index';
+
+async function main(tagName: string) {
+ const name = tagName.toLocaleLowerCase();
+ console.log(`Creating component ${name}...`);
+
+ fs.mkdir(name);
+ await fs.writeFile(`${name}/${name}.tag`, tag.replace(/\$name/g, name));
+ await fs.writeFile(`${name}/${name}.scss`, scss.replace(/\$name/g, name));
+ await fs.writeFile(`${name}/${name}.js`, index.replace(/\$name/g, name));
+};
+
+program
+ .version('1.0.0')
+ .arguments('<name>')
+ .action(name => {
+ main(name);
+ })
+ .usage('create-riot-component [name]')
+ .parse(process.argv); \ No newline at end of file