(...objs)
| 92 | } |
| 93 | |
| 94 | const createTestdir = (...objs) => { |
| 95 | const testdirHelper = (obj, ancestors = []) => { |
| 96 | for (const [key, value] of Object.entries(obj)) { |
| 97 | if (extname(key) === '.json') { |
| 98 | obj[key] = JSON.stringify(value, null, 2) |
| 99 | } else if (extname(key) === '.js' || ancestors.slice(-2).join('/') === 'node_modules/.bin') { |
| 100 | // a js or bin file is converted to a bin script that writes a file |
| 101 | obj[key] = `#!/usr/bin/env node\nrequire('fs').writeFileSync( |
| 102 | 'output-${value.key.replace('/', '-')}', |
| 103 | JSON.stringify({ |
| 104 | value: '${value.value}', |
| 105 | args: process.argv.slice(2), |
| 106 | created: '${[...ancestors, key].join('/')}', |
| 107 | }) |
| 108 | )` |
| 109 | } else if (value && typeof value === 'object') { |
| 110 | obj[key] = testdirHelper(value, [...ancestors, key]) |
| 111 | } else { |
| 112 | obj[key] = value |
| 113 | } |
| 114 | } |
| 115 | return obj |
| 116 | } |
| 117 | |
| 118 | return testdirHelper(merge(...objs)) |
| 119 | } |
| 120 | |
| 121 | const setup = (t, { |
| 122 | pkg, |
no test coverage detected