Skip to content

Commit

Permalink
fix: fix named imports picocolors issue
Browse files Browse the repository at this point in the history
  • Loading branch information
marsidev committed Sep 3, 2022
1 parent 561ae7a commit 6159ae5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
18 changes: 9 additions & 9 deletions src/index.ts
@@ -1,14 +1,14 @@
#!/usr/bin/env node

import path from 'path'
import { cyan } from 'picocolors'
import pc from 'picocolors'
import { createEmptyFile, ensureDir, fileExists, validFilename } from './utils/fs'
import { cli } from './utils/cli'
import { type LogOptions, error, log, success, warn } from './utils/log'

const main = () => {
if (Object.keys(cli).length <= 3 && cli._.length === 0) {
const cmd = cyan(`${cli.$0} --help`)
const cmd = pc.cyan(`${cli.$0} --help`)
warn(`No filenames provided. Use the command "${cmd}" for help`)
return
}
Expand All @@ -20,9 +20,9 @@ const main = () => {

if (cli.author) {
const options: LogOptions = { ...logOptions, silent: false }
log(`Name: ${cyan('Luis Marsiglia')}`, options)
log(`GitHub: ${cyan('https://github.com/marsidev')}`, options)
log(`Twitter: ${cyan('https://twitter.com/marsigliacr')}`, options)
log(`Name: ${pc.cyan('Luis Marsiglia')}`, options)
log(`GitHub: ${pc.cyan('https://github.com/marsidev')}`, options)
log(`Twitter: ${pc.cyan('https://twitter.com/marsigliacr')}`, options)
return
}

Expand All @@ -41,22 +41,22 @@ const main = () => {
const parsed = path.parse(filenamePath)

if (fileExists(filename)) {
warn(`File ${cyan(filename)} already exists`, logOptions)
warn(`File ${pc.cyan(filename)} already exists`, logOptions)
return
}

if (!validFilename(parsed.base)) {
error(`${cyan(parsed.base)} is not a valid filename`, logOptions)
error(`${pc.cyan(parsed.base)} is not a valid filename`, logOptions)
return
}

parsed.dir && ensureDir(parsed.dir)

try {
createEmptyFile(filenamePath)
success(`File ${cyan(filenamePath)} created`, logOptions)
success(`File ${pc.cyan(filenamePath)} created`, logOptions)
} catch (e) {
error(`Something went wrong while creating the file ${cyan(filename)}`, logOptions)
error(`Something went wrong while creating the file ${pc.cyan(filename)}`, logOptions)
console.log(e)
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/log.ts
@@ -1,4 +1,5 @@
import { blue, bold, green, red, yellow } from 'picocolors'
import pc from 'picocolors'
const { blue, bold, green, red, yellow } = pc

export interface LogOptions {
silent?: boolean
Expand Down

0 comments on commit 6159ae5

Please sign in to comment.