Skip to content

Commit

Permalink
fix: remove todos and add throw error on edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ipetinate committed May 8, 2024
1 parent 9919f9c commit 0ff6a5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
12 changes: 2 additions & 10 deletions src/actions/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,8 @@ export async function createAction(resourceName, options) {
*/
let preset = options.preset

if (!options.type) {
// TODO: prompt type
}

if (!options.framework) {
// TODO: prompt framework
}

if (!options.path) {
// TODO: prompt framework
if (!options.type || !options.framework || !options.path) {
throw new Error('You did not pass any of the mandatory parameters for Options Mode')
}

if (!preset && options.framework) {
Expand Down
8 changes: 7 additions & 1 deletion src/generators/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function makeFolderWrapperOrBypass(data) {
const folderWrapperPath = join(data.resourcePath, data.name)
const folderWrapperExists = checkDirectoriesTree(splitPathString(folderWrapperPath))

if (!folderWrapperExists) {
if (data.folderWrapper && !folderWrapperExists) {
const created = createDir(folderWrapperPath)

if (!created) console.error('Error: cannot create folder wrapper.')
Expand Down Expand Up @@ -238,5 +238,11 @@ export function generateComponentFile(data) {
const path = data.pathWithFileName
const success = createFileWithContent(data.pathWithFileName, data.fileContent)

if (data.folderWrapper) {
const filePath = join(data.resourcePath, data.name, 'index.' + data.extension)

createFileWithContent(filePath, `export * from './${data.name}'`)
}

return { success, path }
}

0 comments on commit 0ff6a5b

Please sign in to comment.