File tree Expand file tree Collapse file tree 4 files changed +9
-11
lines changed Expand file tree Collapse file tree 4 files changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ export async function finalizeAddOns(
100100 let addOn : AddOn | undefined
101101 const localAddOn = addOns . find ( ( a ) => a . id === addOnID )
102102 if ( localAddOn ) {
103- addOn = localAddOn
103+ addOn = loadAddOn ( localAddOn )
104104 } else if ( addOnID . startsWith ( 'http' ) ) {
105105 addOn = await loadRemoteAddOn ( addOnID )
106106 } else {
@@ -131,12 +131,11 @@ export async function listAddOns(options: CliOptions) {
131131 }
132132}
133133
134- function loadAddOn ( path : string ) : AddOn {
135- const fileContent = await readFile ( path , 'utf-8' )
136- return JSON . parse ( fileContent )
134+ function loadAddOn ( addOn : AddOn ) : AddOn {
135+ return addOn
137136}
138137
139- async function loadRemoteAddOn ( url : string ) : AddOn {
138+ async function loadRemoteAddOn ( url : string ) : Promise < AddOn > {
140139 const response = await fetch ( url )
141140 const fileContent = await response . json ( )
142141 return JSON . parse ( fileContent )
Original file line number Diff line number Diff line change @@ -3,8 +3,7 @@ import { resolve } from 'node:path'
33
44import { CONFIG_FILE } from './constants.js'
55
6- import type { Environment } from './environment'
7- import type { Options } from './types'
6+ import type { Environment , Options } from './types'
87
98export type PersistedOptions = Exclude <
109 Partial < Options > ,
Original file line number Diff line number Diff line change @@ -251,6 +251,7 @@ async function copyAddOnFile(
251251 environment : Environment ,
252252 content : string ,
253253 target : string ,
254+ targetPath : string ,
254255 templateFile : ( content : string , targetFileName : string ) => Promise < void > ,
255256) {
256257 let targetFile = basename ( target ) . replace ( / _ d o t _ / , '.' )
@@ -265,8 +266,6 @@ async function copyAddOnFile(
265266 isAppend = true
266267 }
267268
268- const targetPath = resolve ( dirname ( target ) , targetFile )
269-
270269 if ( isTemplate ) {
271270 await templateFile ( content , targetPath )
272271 } else {
@@ -445,10 +444,11 @@ export async function createApp(
445444 s ?. start ( `Setting up ${ addOn . name } ...` )
446445 if ( addOn . files ) {
447446 for ( const file of Object . keys ( addOn . files ) ) {
448- copyAddOnFile (
447+ await copyAddOnFile (
449448 environment ,
450449 addOn . files [ file ] ,
451450 file ,
451+ resolve ( targetDir , file ) ,
452452 ( content , targetFileName ) =>
453453 templateFileFromContent ( targetFileName , content ) ,
454454 )
Original file line number Diff line number Diff line change 1- import type { Environment } from './environment '
1+ import type { Environment } from './types.js '
22
33export const SUPPORTED_PACKAGE_MANAGERS = [
44 'npm' ,
You can’t perform that action at this time.
0 commit comments