Skip to content

Commit 27d8296

Browse files
committed
fix(paths): emit clickable hyperlinks for printed paths
1 parent 3d16e4c commit 27d8296

5 files changed

Lines changed: 33 additions & 3 deletions

File tree

‎packages/nuxt-cli/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@bomb.sh/tab": "^0.0.19",
4949
"@clack/prompts": "^1.7.0",
5050
"citty": "^0.2.2",
51+
"clickable-path": "^0.0.1",
5152
"confbox": "^0.2.4",
5253
"consola": "^3.4.2",
5354
"defu": "^6.1.7",

‎packages/nuxt-cli/src/utils/paths.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import{delimiter}from'node:path'
1+
import{delimiter,relative}from'node:path'
22
importprocessfrom'node:process'
3-
import{relative}from'pathe'
3+
import{link}from'clickable-path'
44

55
constcwd=process.cwd()
66

77
exportfunctionrelativeToProcess(path: string){
8-
returnrelative(cwd,path)||path
8+
returnlink(path,{
9+
cwd,
10+
formatter: absolute=>relative(cwd,absolute)||absolute,
11+
})
912
}
1013

1114
exportfunctionwithNodePath(path: string){
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import{join}from'node:path'
2+
importprocessfrom'node:process'
3+
4+
import{describe,expect,it,vi}from'vitest'
5+
6+
import{relativeToProcess}from'../../../src/utils/paths'
7+
8+
describe('relativeToProcess',()=>{
9+
it('should label paths relative to the working directory',()=>{
10+
vi.stubEnv('FORCE_HYPERLINK','0')
11+
expect(relativeToProcess(join(process.cwd(),'src','app.vue'))).toBe(join('src','app.vue'))
12+
expect(relativeToProcess(process.cwd())).toBe(process.cwd())
13+
})
14+
})

‎pnpm-lock.yaml‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
minimumReleaseAgeExclude:
2+
- clickable-path
3+
14
packages:
25
- packages/*
36
- packages/nuxt-cli/test/fixtures/*

0 commit comments

Comments
 (0)