summaryrefslogtreecommitdiffstats
path: root/scripts/generate-undici-types-package-json.js
blob: 78095ae6d5e4a03e130023a58252f66fcc574bd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const fs = require('node:fs')
const path = require('node:path')

const packageJSONPath = path.join(__dirname, '..', 'package.json')
const packageJSONRaw = fs.readFileSync(packageJSONPath, 'utf-8')
const packageJSON = JSON.parse(packageJSONRaw)

const licensePath = path.join(__dirname, '..', 'LICENSE')
const licenseRaw = fs.readFileSync(licensePath, 'utf-8')

const packageTypesJSON = {
  name: 'undici-types',
  version: packageJSON.version,
  description: 'A stand-alone types package for Undici',
  homepage: packageJSON.homepage,
  bugs: packageJSON.bugs,
  repository: packageJSON.repository,
  license: packageJSON.license,
  types: 'index.d.ts',
  files: ['*.d.ts'],
  contributors: packageJSON.contributors
}

const packageTypesPath = path.join(__dirname, '..', 'types', 'package.json')
const licenseTypesPath = path.join(__dirname, '..', 'types', 'LICENSE')

fs.writeFileSync(packageTypesPath, JSON.stringify(packageTypesJSON, null, 2))
fs.writeFileSync(licenseTypesPath, licenseRaw)