From 7f953954a25071d55e61d33ec9f6641fe283de9c Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Thu, 28 Dec 2017 14:05:57 +0200 Subject: Initial commit --- src/index.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/index.ts (limited to 'src/index.ts') 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('') + .action(name => { + main(name); + }) + .usage('create-riot-component [name]') + .parse(process.argv); \ No newline at end of file -- cgit v1.3