-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* List command added. * 'fs' not defined fixed and logo added. * Installation should be global. * Version updated.
- Loading branch information
1 parent
1f0314f
commit 80b44ab
Showing
3 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const chalk = require('chalk'); | ||
|
||
const { logo } = require('../helpers/print'); | ||
|
||
exports.command = 'list' | ||
exports.desc = 'List all kitty components.' | ||
|
||
exports.handler = function () { | ||
try { | ||
const projectPath = process.cwd(); | ||
|
||
// check if kitty dir exists | ||
if(!fs.existsSync(path.resolve(projectPath, './kitty'))) { | ||
throw new Error('Kitty dir does not exist. Please run "kitty init" to initialize kitty dir.') | ||
} | ||
|
||
const kittyDir = fs.readdirSync(path.resolve(projectPath, './kitty')); | ||
logo(); | ||
console.log(chalk.green('Kitty components:')); | ||
console.log(''); | ||
for(let i = 0; i < kittyDir.length; i++) { | ||
// check if dir | ||
if(fs.lstatSync(path.resolve(projectPath, `./kitty/${kittyDir[i]}`)).isDirectory()) { | ||
console.log(chalk.cyan(kittyDir[i])); | ||
} | ||
} | ||
|
||
} catch (error) { | ||
console.log(chalk.red(error.message)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters