All files / src util.ts

84.62% Statements 11/13
62.5% Branches 5/8
80% Functions 4/5
90% Lines 9/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 192x 2x   58x 58x       2x 2x     29x 29x     29x    
import { promises as fs } from 'fs'
import path from 'path'
 
export const loadJSON = async (path:string):Promise<object> => {
  return JSON.parse(await fs.readFile(path, { encoding: 'utf8' }))
}
 
// This is required for both es6 and commonjs support
Eif (!global?.['__dirname']) {
  (global as any).__dirname = undefined
}
 
export const baseSchemaLocation = async () => {
  Iif (!__dirname) {
    return (await import('./url.js')).es6SchemaLocation
  }
  return path.join(__dirname, '/../schema/')
}