Upgrade Ava to v4

This commit is contained in:
Henry Mercer 2022-02-01 18:01:11 +00:00
parent 9a40cc5274
commit ce89f1b611
1153 changed files with 27264 additions and 95308 deletions

33
node_modules/load-json-file/index.js generated vendored
View file

@ -1,23 +1,24 @@
'use strict';
const path = require('path');
const fs = require('graceful-fs');
const stripBom = require('strip-bom');
const parseJson = require('parse-json');
const pify = require('pify');
import {readFileSync, promises as fs} from 'node:fs';
const parse = (data, filePath, options = {}) => {
data = stripBom(data);
const {readFile} = fs;
if (typeof options.beforeParse === 'function') {
data = options.beforeParse(data);
const parse = (buffer, {beforeParse, reviver} = {}) => {
// Unlike `buffer.toString()` and `fs.readFile(path, 'utf8')`, `TextDecoder`` will remove BOM.
let data = new TextDecoder().decode(buffer);
if (typeof beforeParse === 'function') {
data = beforeParse(data);
}
return parseJson(data, options.reviver, path.relative(process.cwd(), filePath));
return JSON.parse(data, reviver);
};
const loadJsonFile = (filePath, options) => pify(fs.readFile)(filePath, 'utf8').then(data => parse(data, filePath, options));
export async function loadJsonFile(filePath, options) {
const buffer = await readFile(filePath);
return parse(buffer, options);
}
module.exports = loadJsonFile;
// TODO: Remove this for the next major release
module.exports.default = loadJsonFile;
module.exports.sync = (filePath, options) => parse(fs.readFileSync(filePath, 'utf8'), filePath, options);
export function loadJsonFileSync(filePath, options) {
const buffer = readFileSync(filePath);
return parse(buffer, options);
}