@@ -2,6 +2,7 @@ import ValTown from "@valtown/sdk";
22import { memoize } from "@std/cache" ;
33import manifest from "../deno.json" with { type : "json" } ;
44import { API_KEY_KEY , DEFAULT_BRANCH_NAME } from "~/consts.ts" ;
5+ import { normalize } from "@std/path" ;
56
67const sdk = new ValTown ( {
78 // Must get set in vt.ts entrypoint if not set as an env var!
@@ -63,7 +64,7 @@ export async function branchExists(
6364 branchName : string ,
6465) : Promise < boolean > {
6566 for await ( const branch of sdk . vals . branches . list ( valId , { } ) ) {
66- if ( branch . name == branchName ) return true ;
67+ if ( branch . name === branchName ) return true ;
6768 }
6869 return false ;
6970}
@@ -81,7 +82,7 @@ export async function branchNameToBranch(
8182 branchName : string ,
8283) : Promise < ValTown . Vals . Branches . BranchListResponse > {
8384 for await ( const branch of sdk . vals . branches . list ( valId , { } ) ) {
84- if ( branch . name == branchName ) return branch ;
85+ if ( branch . name === branchName ) return branch ;
8586 }
8687
8788 throw new Deno . errors . NotFound ( `Branch "${ branchName } " not found in Val` ) ;
@@ -118,7 +119,7 @@ export async function valItemExists(
118119 * @param valId - The ID of the Val containing the file
119120 * @param options - The options object
120121 * @param options.branchId - The ID of the Val branch to reference
121- * @param [ options.version] - The version of the Val for the file being found (optional)
122+ * @param options.version - The version of the Val for the file being found (optional)
122123 * @param options.filePath - The file path to locate
123124 * @returns Promise resolving to the file data or undefined if not found
124125 */
@@ -140,11 +141,11 @@ export const getValItem = memoize(async (
140141/**
141142 * Get the content of a Val item.
142143 *
143- * @param { string } valId The ID of the Val
144- * @param { string } branchId The ID of the Val branch to reference
145- * @param { number } version The version of the Val
146- * @param { string } filePath The path to the file
147- * @returns { Promise<string> } Promise resolving to the file content
144+ * @param valId The ID of the Val
145+ * @param branchId The ID of the Val branch to reference
146+ * @param version The version of the Val
147+ * @param filePath The path to the file
148+ * @returns Promise resolving to the file content
148149 */
149150export const getValItemContent = memoize (
150151 async (
@@ -179,14 +180,15 @@ export const listValItems = memoize(async (
179180 ( await branchNameToBranch ( valId , DEFAULT_BRANCH_NAME )
180181 . then ( ( resp ) => resp . id ) ) ;
181182
182- const files = await Array . fromAsync (
183+ const files = ( await Array . fromAsync (
183184 sdk . vals . files . retrieve ( valId , {
184185 path : "" ,
185186 branch_id : branchId ,
186187 version,
187188 recursive : true ,
188189 } ) ,
189- ) ;
190+ ) )
191+ . map ( ( f ) => ( { ...f , path : normalize ( f . path ) } ) ) ;
190192
191193 return files ;
192194} ) ;
0 commit comments