UNPKG

onvif-nvt-ts

Version:

Wrapper for ONVIF spec to control NVT (Network Video Transitter) devices. Forked and added TypeScript support from onvif-nvt.

29 lines (22 loc) 740 B
import fs from 'fs/promises' import path from 'path' import { pd } from 'pretty-data' let writable = false let testDataPath = path.resolve(__dirname, '../../test/data/xml') export async function saveXml(service: string, methodName: string, xml: string) { if (writable) { const prettyXml = pd.xml(xml) const folderPath = testDataPath + `/${service}` // make sure folder exists await fs.mkdir(folderPath, { recursive: true }) const filePath = folderPath + `/${methodName}.xml` await fs.writeFile(filePath, prettyXml) } } export async function setPath(folder: string) { testDataPath = folder await fs.mkdir(folder, { recursive: true }) } export function setWritable(value: boolean) { writable = value }