UNPKG

744 BJavaScriptView Raw
1/* istanbul ignore file */
2'use strict'
3
4const FJS = require('fast-json-stringify')
5const path = require('node:path')
6const fs = require('node:fs')
7
8const code = FJS({
9 type: 'object',
10 properties: {
11 statusCode: { type: 'number' },
12 code: { type: 'string' },
13 error: { type: 'string' },
14 message: { type: 'string' }
15 }
16}, { mode: 'standalone' })
17
18const file = path.join(__dirname, '..', 'lib', 'error-serializer.js')
19
20const moduleCode = `// This file is autogenerated by build/build-error-serializer.js, do not edit
21/* istanbul ignore file */
22${code}
23`
24
25if (require.main === module) {
26 fs.writeFileSync(file, moduleCode)
27 console.log(`Saved ${file} file successfully`)
28} else {
29 module.exports = {
30 code: moduleCode
31 }
32}