Skip to content

@vtj


@vtj / node / outputJsonSync

Function: outputJsonSync()

outputJsonSync(file, data, options?): void

Defined in: packages/node/src/fs.ts:25

Almost the same as writeJsonSync, except that if the directory does not exist, it's created.

Parameters

file

string

data

any

options?

JsonOutputOptions

Returns

void

Example

ts
import * as fs from 'fs-extra'

const file = '/tmp/this/path/does/not/exist/file.json'
fs.outputJsonSync(file, {name: 'JP'})

const data = fs.readJsonSync(file)
console.log(data.name) // => JP

Released under the MIT License.