Skip to content

Commit

Permalink
fix: don't show "copy count was not set" when build failed
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed May 12, 2023
1 parent 6286e93 commit 08894dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const buildPlugin = ({
silent
}: ResolvedViteStaticCopyOptions): Plugin => {
let config: ResolvedConfig
let copyCount: number | undefined

return {
name: 'vite-plugin-static-copy:build',
Expand All @@ -17,14 +16,12 @@ export const buildPlugin = ({
config = _config
},
async writeBundle() {
copyCount = await copyAll(
const copyCount = await copyAll(
config.root,
config.build.outDir,
targets,
flatten
)
},
closeBundle() {
if (!silent) outputCopyLog(config.logger, copyCount)
}
}
Expand Down
9 changes: 2 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,8 @@ export const outputCollectedLog = (logger: Logger, collectedMap: FileMap) => {
}
}

export const outputCopyLog = (
logger: Logger,
copyCount: number | undefined
) => {
if (copyCount === undefined) {
logger.error(formatConsole(pc.yellow('Copy count was not set.')))
} else if (copyCount > 0) {
export const outputCopyLog = (logger: Logger, copyCount: number) => {
if (copyCount > 0) {
logger.info(formatConsole(pc.green(`Copied ${copyCount} items.`)))
} else {
logger.warn(formatConsole(pc.yellow('No items to copy.')))
Expand Down

0 comments on commit 08894dd

Please sign in to comment.