@@ -46,7 +46,6 @@ const presetSources: Record<string, PresetApi> = {
4646 github,
4747 gitlab,
4848 http,
49- internal,
5049 local,
5150 npm,
5251} ;
@@ -120,33 +119,49 @@ export async function getPreset(
120119 }
121120 const { presetSource, repo, presetPath, presetName, tag, params, rawParams } =
122121 parsePreset ( preset ) ;
123- const cacheKey = `preset:${ preset } ` ;
124- const presetCachePersistence = GlobalConfig . get (
125- 'presetCachePersistence' ,
126- false ,
127- ) ;
128122
129123 let presetConfig : Preset | null | undefined ;
130124
131- if ( presetCachePersistence ) {
132- presetConfig = await packageCache . get ( presetCacheNamespace , cacheKey ) ;
133- } else {
134- presetConfig = memCache . get ( cacheKey ) ;
135- }
136-
137- if ( isNullOrUndefined ( presetConfig ) ) {
138- presetConfig = await presetSources [ presetSource ] . getPreset ( {
125+ if ( presetSource === 'internal' ) {
126+ presetConfig = internal . getPreset ( {
139127 repo,
140128 presetPath,
141129 presetName,
142130 tag,
143131 } ) ;
132+ } else {
133+ const cacheKey = `preset:${ preset } ` ;
134+ const presetCachePersistence = GlobalConfig . get (
135+ 'presetCachePersistence' ,
136+ false ,
137+ ) ;
138+
144139 if ( presetCachePersistence ) {
145- await packageCache . set ( presetCacheNamespace , cacheKey , presetConfig , 15 ) ;
140+ presetConfig = await packageCache . get ( presetCacheNamespace , cacheKey ) ;
146141 } else {
147- memCache . set ( cacheKey , presetConfig ) ;
142+ presetConfig = memCache . get ( cacheKey ) ;
143+ }
144+
145+ if ( isNullOrUndefined ( presetConfig ) ) {
146+ presetConfig = await presetSources [ presetSource ] . getPreset ( {
147+ repo,
148+ presetPath,
149+ presetName,
150+ tag,
151+ } ) ;
152+ if ( presetCachePersistence ) {
153+ await packageCache . set (
154+ presetCacheNamespace ,
155+ cacheKey ,
156+ presetConfig ,
157+ 15 ,
158+ ) ;
159+ } else {
160+ memCache . set ( cacheKey , presetConfig ) ;
161+ }
148162 }
149163 }
164+
150165 if ( ! presetConfig ) {
151166 throw new Error ( PRESET_DEP_NOT_FOUND ) ;
152167 }
0 commit comments