@@ -4,6 +4,7 @@ import {mkdir, writeFile} from "node:fs/promises";
44import { dirname , join } from "node:path" ;
55import { parseArgs } from "node:util" ;
66import { getDatabase , getDatabaseConfig , getQueryCachePath } from "../src/databases/index.js" ;
7+ import { getReplacer } from "../src/databases/index.js" ;
78
89if ( process . argv [ 1 ] === import . meta. filename ) run ( ) ;
910
@@ -52,20 +53,14 @@ export default async function run(args?: string[]): Promise<void> {
5253 const database = await getDatabase ( config ) ;
5354 const results = await database . call ( null , strings , ...params ) ;
5455 await mkdir ( dirname ( cachePath ) , { recursive : true } ) ;
55- await writeFile ( cachePath , JSON . stringify ( results , replace ) ) ;
56+ await writeFile ( cachePath , JSON . stringify ( results , await getReplacer ( config ) ) ) ;
5657 console . log ( join ( values . root , cachePath ) ) ;
5758 } catch ( error ) {
5859 console . error ( getErrorMessage ( error ) ) ;
5960 process . exit ( 1 ) ;
6061 }
6162}
6263
63- // Force dates to be serialized as ISO 8601 UTC, undoing this:
64- // https://github.com/snowflakedb/snowflake-connector-nodejs/blob/a9174fb7/lib/connection/result/sf_timestamp.js#L177-L179
65- function replace ( this : { [ key : string ] : unknown } , key : string , value : unknown ) : unknown {
66- return this [ key ] instanceof Date ? Date . prototype . toJSON . call ( this [ key ] ) : value ;
67- }
68-
6964function getErrorMessage ( error : unknown ) : string {
7065 return error instanceof Error &&
7166 "errors" in error && // AggregateError
0 commit comments