Skip to content

Commit 8406b9c

Browse files
committed
fix: replace "node:path" with "pathe"
1 parent b72c59b commit 8406b9c

59 files changed

Lines changed: 82 additions & 66 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/create-app/build.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { existsSync } from 'node:fs'
22
import fs from 'node:fs/promises'
3-
import { dirname, resolve } from 'node:path'
43
import { fileURLToPath } from 'node:url'
4+
import { dirname, resolve } from 'pathe'
55

66
const __dirname = fileURLToPath(new URL('.', import.meta.url))
77
const __templateDir = resolve(__dirname, 'template')

packages/create-app/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
import fs from 'node:fs'
55
import { createRequire } from 'node:module'
6-
import path from 'node:path'
76
// @ts-check
87
import process from 'node:process'
98
import { fileURLToPath } from 'node:url'
109
import { blue, bold, cyan, dim, green, yellow } from 'ansis'
1110
import minimist from 'minimist'
11+
import path from 'pathe'
1212
import prompts from 'prompts'
1313
import { x } from 'tinyexec'
1414

packages/create-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"dependencies": {
3131
"ansis": "catalog:prod",
3232
"minimist": "catalog:prod",
33+
"pathe": "catalog:prod",
3334
"prompts": "catalog:prod",
3435
"tinyexec": "catalog:prod"
3536
}

packages/create-theme/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
import fs from 'node:fs'
55
import { createRequire } from 'node:module'
6-
import path from 'node:path'
76
// @ts-check
87
import process from 'node:process'
98
import { fileURLToPath } from 'node:url'
109
import { blue, bold, cyan, dim, green, yellow } from 'ansis'
1110
import minimist from 'minimist'
11+
import path from 'pathe'
1212
import prompts from 'prompts'
1313

1414
const argv = minimist(process.argv.slice(2))

packages/create-theme/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"dependencies": {
2323
"ansis": "catalog:prod",
2424
"minimist": "catalog:prod",
25+
"pathe": "catalog:prod",
2526
"prompts": "catalog:prod"
2627
}
2728
}

packages/parser/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"dependencies": {
3737
"@antfu/utils": "catalog:frontend",
3838
"@slidev/types": "workspace:*",
39+
"pathe": "catalog:prod",
3940
"yaml": "catalog:prod"
4041
},
4142
"devDependencies": {

packages/parser/src/fs.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,22 @@ import type {
88
} from '@slidev/types'
99
import { existsSync } from 'node:fs'
1010
import { readFile, writeFile } from 'node:fs/promises'
11-
import { dirname, resolve } from 'node:path'
1211
import { slash } from '@antfu/utils'
12+
import { dirname, isAbsolute, relative, resolve } from 'pathe'
1313
import YAML from 'yaml'
1414
import { detectFeatures, parse, parseRangeString, stringify } from './core'
15-
import { isPathInsideRoots } from './utils'
15+
16+
/**
17+
* Whether `filePath` resolves inside any of `roots` (no `..` escape).
18+
* Inlined here (rather than imported from the `slidev` package) because
19+
* `@slidev/parser` must stay independent of `@slidev/slidev`.
20+
*/
21+
export function isPathInsideRoots(filePath: string, roots: string[]): boolean {
22+
return roots.some((root) => {
23+
const rel = relative(root, filePath)
24+
return rel === '' || (!!rel && !rel.startsWith('..') && !isAbsolute(rel))
25+
})
26+
}
1627

1728
const RE_FRONTMATTER_START = /^---(?:[^-].*)?$/
1829
const RE_BLANK_LINE = /^\s*$/

packages/parser/src/utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from 'vitest'
2-
import { isPathInsideRoots } from './utils'
2+
import { isPathInsideRoots } from './fs'
33

44
describe('isPathInsideRoots', () => {
55
it('accepts a path nested inside a root', () => {

packages/parser/src/utils.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1-
import { isAbsolute, relative } from 'node:path'
21
import { isNumber, range, uniq } from '@antfu/utils'
32

43
export * from './timesplit'
54

6-
/**
7-
* Whether `filePath` resolves inside any of `roots` (no `..` escape).
8-
* Inlined here (rather than imported from the `slidev` package) because
9-
* `@slidev/parser` must stay independent of `@slidev/slidev`.
10-
*/
11-
export function isPathInsideRoots(filePath: string, roots: string[]): boolean {
12-
return roots.some((root) => {
13-
const rel = relative(root, filePath)
14-
return rel === '' || (!!rel && !rel.startsWith('..') && !isAbsolute(rel))
15-
})
16-
}
17-
185
const RE_ASPECT_RATIO_SEPARATOR = /[:/x|]/
196

207
/**

packages/slidev/node/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import type { Argv } from 'yargs'
44
import { execFile } from 'node:child_process'
55
import fs from 'node:fs/promises'
66
import os from 'node:os'
7-
import path from 'node:path'
87
import process from 'node:process'
98
import * as readline from 'node:readline'
109
import { verifyConfig } from '@slidev/parser'
1110
import { blue, bold, cyan, cyanBright, dim, gray, green, underline, yellow } from 'ansis'
1211
import equal from 'fast-deep-equal'
1312
import { getPort } from 'get-port-please'
1413
import openBrowser from 'open'
14+
import path from 'pathe'
1515
import yargs from 'yargs'
1616
import { version } from '../package.json'
1717
import { createServer } from './commands/serve'
@@ -725,7 +725,7 @@ function printInfo(
725725
if (options.utils.define.__SLIDEV_FEATURE_BROWSER_EXPORTER__)
726726
console.log(`${dim(' export slides')} > ${blue(`${baseUrl}/export/`)}`)
727727
if (options.mode === 'dev' && options.data.config.mcp !== false)
728-
console.log(`${dim(' mcp server (ai)')} > ${blue(`http://localhost:${bold(port)}/__mcp`)}`)
728+
console.log(`${dim(' mcp server ')} > ${blue(`http://localhost:${bold(port)}/__mcp`)}`)
729729
if (options.inspect)
730730
console.log(`${dim(' vite inspector')} > ${yellow(`${baseUrl}/__inspect/`)}`)
731731

0 commit comments

Comments
 (0)