File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -61,13 +61,25 @@ export function getCLIRoot() {
61
61
return resolve ( __dirname , '..' )
62
62
}
63
63
64
- export function getThemeRoots ( name : string ) {
64
+ export function isRelative ( name : string ) {
65
+ return / ^ \. \. ? [ \/ \\ ] / . test ( name )
66
+ }
67
+
68
+ export function getThemeRoots ( name : string , entry : string ) {
65
69
if ( ! name )
66
70
return [ ]
67
71
68
- return [
69
- dirname ( require . resolve ( `${ name } /package.json` ) ) ,
70
- ]
72
+ // TODO: handle theme inherit
73
+ if ( isRelative ( name ) ) {
74
+ return [
75
+ resolve ( dirname ( entry ) , name ) ,
76
+ ]
77
+ }
78
+ else {
79
+ return [
80
+ dirname ( require . resolve ( `${ name } /package.json` ) ) ,
81
+ ]
82
+ }
71
83
}
72
84
73
85
export async function resolveOptions (
@@ -95,7 +107,7 @@ export async function resolveOptions(
95
107
96
108
const clientRoot = getClientRoot ( )
97
109
const cliRoot = getCLIRoot ( )
98
- const themeRoots = getThemeRoots ( theme )
110
+ const themeRoots = getThemeRoots ( theme , entry )
99
111
const roots = uniq ( [ clientRoot , ...themeRoots , userRoot ] )
100
112
101
113
return {
Original file line number Diff line number Diff line change 1
1
import prompts from 'prompts'
2
2
import { parseNi , run } from '@antfu/ni'
3
+ import { isRelative } from './options'
3
4
4
5
const officialThemes : Record < string , string > = {
5
6
none : '' ,
@@ -21,6 +22,8 @@ export function resolveThemeName(name: string) {
21
22
return ''
22
23
if ( name . startsWith ( '@slidev/theme-' ) || name . startsWith ( 'slidev-theme-' ) )
23
24
return name
25
+ if ( name . startsWith ( '.' ) )
26
+ return name
24
27
if ( officialThemes [ name ] !== null )
25
28
return officialThemes [ name ]
26
29
@@ -32,7 +35,7 @@ export async function promptForThemeInstallation(name: string) {
32
35
if ( ! name )
33
36
return name
34
37
35
- if ( packageExists ( name ) )
38
+ if ( isRelative ( name ) || packageExists ( name ) )
36
39
return name
37
40
38
41
const { confirm } = await prompts ( {
You can’t perform that action at this time.
0 commit comments