fix: use pathe instead of path

This commit is contained in:
Anthony Fu 2021-12-18 20:22:30 +08:00
parent c5ee9efd8b
commit ce8e944d64
21 changed files with 32 additions and 21 deletions

View File

@ -1,3 +1,11 @@
{
"extends": "@antfu"
"extends": "@antfu",
"rules": {
"no-restricted-imports": [
"error",
{
"paths": ["path"]
}
]
}
}

View File

@ -35,6 +35,7 @@
"esno": "^0.13.0",
"fast-glob": "^3.2.7",
"npm-run-all": "^4.1.5",
"pathe": "^0.2.0",
"pnpm": "^6.24.1",
"rimraf": "^3.0.2",
"rollup-plugin-dts": "^4.0.1",

View File

@ -1,5 +1,5 @@
import { dirname, resolve } from 'path'
import { fileURLToPath } from 'url'
import { dirname, resolve } from 'pathe'
import type { Plugin } from 'vite'
import sirv from 'sirv'
import { WebSocketServer } from 'ws'

View File

@ -1,4 +1,4 @@
import { resolve } from 'path'
import { resolve } from 'pathe'
import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'

View File

@ -1,7 +1,7 @@
#!/usr/bin/env node
import { fileURLToPath } from 'url'
import { resolve } from 'path'
import { resolve } from 'pathe'
import { ensurePackageInstalled } from '../dist/utils.js'
const argv = process.argv.slice(2)

View File

@ -1,5 +1,5 @@
import { resolve } from 'path'
import { fileURLToPath } from 'url'
import { resolve } from 'pathe'
export const distDir = resolve(fileURLToPath(import.meta.url), '../../dist')

View File

@ -1,4 +1,4 @@
import path from 'path'
import path from 'pathe'
import { expect } from 'chai'
import type { SnapshotResult, Test } from '../../types'
import { rpc } from '../../runtime/rpc'

View File

@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
import path from 'path'
import fs from 'fs'
import path from 'pathe'
import naturalCompare from 'natural-compare'
import type { OptionsReceived as PrettyFormatOptions } from 'pretty-format'
import {

View File

@ -1,4 +1,4 @@
import { resolve } from 'path'
import { resolve } from 'pathe'
import type { ResolvedConfig as ResolvedViteConfig } from 'vite'
import type { ResolvedConfig, UserConfig } from '../types'
import { defaultExclude, defaultInclude, defaultPort } from '../constants'

View File

@ -1,7 +1,7 @@
import { builtinModules, createRequire } from 'module'
import { fileURLToPath, pathToFileURL } from 'url'
import { dirname, resolve } from 'path'
import vm from 'vm'
import { dirname, resolve } from 'pathe'
import { isValidNodeImport } from 'mlly'
import type { ModuleCache } from '../types'
import { slash } from '../utils'

View File

@ -1,4 +1,4 @@
import { resolve } from 'path'
import { resolve } from 'pathe'
import type { ViteDevServer, InlineConfig as ViteInlineConfig, UserConfig as ViteUserConfig } from 'vite'
import { createServer, mergeConfig } from 'vite'
import { findUp } from 'find-up'

View File

@ -1,6 +1,6 @@
import { resolve } from 'path'
import { MessageChannel } from 'worker_threads'
import { pathToFileURL } from 'url'
import { resolve } from 'pathe'
import type { Options as TinypoolOptions } from 'tinypool'
import { Tinypool } from 'tinypool'
import type { RpcMap } from 'vitest'

View File

@ -1,5 +1,5 @@
import { performance } from 'perf_hooks'
import { relative } from 'path'
import { relative } from 'pathe'
import c from 'picocolors'
import type { Reporter, TaskResultPack, UserConsoleLog } from '../types'
import { getSuites, getTests } from '../utils'

View File

@ -1,8 +1,8 @@
/* eslint-disable prefer-template */
/* eslint-disable no-template-curly-in-string */
import { existsSync, promises as fs } from 'fs'
import { relative } from 'path'
import { format } from 'util'
import { relative } from 'pathe'
import c from 'picocolors'
import * as diff from 'diff'
import type { RawSourceMap } from 'source-map'

View File

@ -1,4 +1,4 @@
import { basename, dirname, isAbsolute, relative } from 'path'
import { basename, dirname, isAbsolute, relative } from 'pathe'
import { createLogUpdate } from 'log-update'
import c from 'picocolors'
import cliTruncate from 'cli-truncate'

View File

@ -1,5 +1,5 @@
import { basename } from 'path'
import { performance } from 'perf_hooks'
import { basename } from 'pathe'
import { nanoid } from 'nanoid/non-secure'
import type { File, ResolvedConfig, Suite, Test } from '../types'
import { interpretOnlyMode } from '../utils'

View File

@ -1,4 +1,4 @@
import { resolve } from 'path'
import { resolve } from 'pathe'
import { nanoid } from 'nanoid/non-secure'
import type { ModuleCache, ResolvedConfig, WorkerContext } from '../types'
import { distDir } from '../constants'

2
pnpm-lock.yaml generated
View File

@ -17,6 +17,7 @@ importers:
esno: ^0.13.0
fast-glob: ^3.2.7
npm-run-all: ^4.1.5
pathe: ^0.2.0
pnpm: ^6.24.1
rimraf: ^3.0.2
rollup-plugin-dts: ^4.0.1
@ -40,6 +41,7 @@ importers:
esno: 0.13.0_typescript@4.5.4
fast-glob: 3.2.7
npm-run-all: 4.1.5
pathe: 0.2.0
pnpm: 6.24.1
rimraf: 3.0.2
rollup-plugin-dts: 4.0.1_typescript@4.5.4

View File

@ -1,6 +1,6 @@
import { resolve } from 'path'
import fs from 'fs/promises'
import { fileURLToPath } from 'url'
import { resolve } from 'pathe'
import { describe, expect, it } from 'vitest'
import { timeout } from '../src/timeout'

View File

@ -1,4 +1,4 @@
import { resolve } from 'path'
import { resolve } from 'pathe'
import fg from 'fast-glob'
import { execa } from 'execa'
import { describe, expect, it } from 'vitest'

View File

@ -18,7 +18,7 @@ describe('Button with increment', async() => {
await window.happyDOM.whenAsyncComplete()
})
function getInsideButton(): HTMLElement | null {
function getInsideButton(): HTMLElement | null | undefined {
return document.body.querySelector('my-button')?.shadowRoot?.querySelector('button')
}
@ -29,13 +29,13 @@ describe('Button with increment', async() => {
it('should show name props', () => {
getInsideButton()
expect(document.body.querySelector('my-button')?.shadowRoot?.innerHTML).to.contain('World')
expect(document.body.querySelector('my-button')?.shadowRoot?.innerHTML).toContain('World')
})
it('should dispatch count event on button click', () => {
const spyClick = spy()
document.querySelector('my-button').addEventListener('count', spyClick)
document.querySelector('my-button')!.addEventListener('count', spyClick)
getInsideButton()?.click()