Skip to content

Commit

Permalink
chore(vite-node): use picocolors
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 27, 2022
1 parent 15244c6 commit 53157a3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 43 deletions.
2 changes: 1 addition & 1 deletion packages/vite-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@
},
"dependencies": {
"debug": "^4.3.4",
"kolorist": "^1.5.1",
"mlly": "^0.5.4",
"pathe": "^0.2.0",
"vite": "^2.9.12 || ^3.0.0-0"
},
"devDependencies": {
"picocolors": "^1.0.0",
"@types/debug": "^4.1.7",
"cac": "^6.7.12",
"rollup": "^2.77.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/vite-node/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cac from 'cac'
import { red } from 'kolorist'
import c from 'picocolors'
import { createServer } from 'vite'
import { version } from '../package.json'
import { ViteNodeServer } from './server'
Expand Down Expand Up @@ -34,7 +34,7 @@ export interface CliOptions {

async function run(files: string[], options: CliOptions = {}) {
if (!files.length) {
console.error(red('No files specified.'))
console.error(c.red('No files specified.'))
cli.outputHelp()
process.exit(1)
}
Expand Down
6 changes: 3 additions & 3 deletions packages/vite-node/src/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { existsSync, promises as fs } from 'fs'
import { join, resolve } from 'pathe'
import type { TransformResult } from 'vite'
import { gray } from 'kolorist'
import c from 'picocolors'
import type { DebuggerOptions } from './types'

function hashCode(s: string) {
Expand All @@ -19,9 +19,9 @@ export class Debugger {
this.dumpDir = resolve(root, options.dumpModules === true ? '.vite-node/dump' : options.dumpModules)
if (this.dumpDir) {
if (options.loadDumppedModules)
console.info(gray(`[vite-node] [debug] load modules from ${this.dumpDir}`))
console.info(c.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`))
else
console.info(gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`))
console.info(c.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`))
}
this.initPromise = this.clearDump()
}
Expand Down
8 changes: 4 additions & 4 deletions packages/vite-node/src/hmr/hmr.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
import type { ErrorPayload, FullReloadPayload, HMRPayload, PrunePayload, Update, UpdatePayload } from 'vite/types/hmrPayload'
import { cyan } from 'kolorist'
import c from 'picocolors'
import createDebug from 'debug'
import type { ViteNodeRunner } from '../client'
import type { HotContext } from '../types'
Expand Down Expand Up @@ -162,7 +162,7 @@ async function fetchUpdate(runner: ViteNodeRunner, { path, acceptedPath }: Updat
fn(deps.map(dep => moduleMap.get(dep)))

const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`
console.log(`${cyan('[vite-node]')} hot updated: ${loggedPath}`)
console.log(`${c.cyan('[vite-node]')} hot updated: ${loggedPath}`)
}
}

Expand Down Expand Up @@ -195,7 +195,7 @@ export async function handleMessage(runner: ViteNodeRunner, emitter: HMREmitter,
}
else {
// css-update
console.error(`${cyan('[vite-node]')} no support css hmr.}`)
console.error(`${c.cyan('[vite-node]')} no support css hmr.}`)
}
})
break
Expand All @@ -212,7 +212,7 @@ export async function handleMessage(runner: ViteNodeRunner, emitter: HMREmitter,
case 'error': {
notifyListeners(runner, 'vite:error', payload)
const err = payload.err
console.error(`${cyan('[vite-node]')} Internal Server Error\n${err.message}\n${err.stack}`)
console.error(`${c.cyan('[vite-node]')} Internal Server Error\n${err.message}\n${err.stack}`)
break
}
}
Expand Down
29 changes: 0 additions & 29 deletions packages/vitest/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1087,35 +1087,6 @@ Repository: lukeed/kleur
---------------------------------------

## kolorist
License: MIT
By: Marvin Hagemeister
Repository: https://github.com/marvinhagemeister/kolorist.git

> The MIT License (MIT)
>
> Copyright (c) 2020-present Marvin Hagemeister
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
---------------------------------------

## locate-path
License: MIT
By: Sindre Sorhus
Expand Down
9 changes: 5 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 53157a3

Please sign in to comment.