Smarter dump test switch

This commit is contained in:
Bán Dénes 2021-07-16 13:31:52 +02:00
parent b43b71998a
commit cd0ae6d38b
2 changed files with 528 additions and 6 deletions

View file

@ -39,16 +39,20 @@ const test = function(input_path) {
// if we're just creating the reference, we can dump the current output
if (dump) {
const out = path.join(
path.dirname(input_path),
path.basename(input_path, '.yaml') + '___ref_candidate'
)
// whole dump
if (dump === true) {
fs.writeJSONSync(out + '.json', actual, {spaces: 4})
if (dump === true || dump === 'true') {
const out = path.join(
path.dirname(input_path),
path.basename(input_path, '.yaml') + '___ref_candidate.json'
)
fs.writeJSONSync(out, actual, {spaces: 4})
// partial, type-specific dump
} else {
const part = u.deep(actual, dump)
const out = path.join(
path.dirname(input_path),
path.basename(input_path, '.yaml') + '___' + dump.split('.').join('_')
)
if (a.type(part)() == 'string') {
fs.writeFileSync(out + '.txt', part)
} else {