Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: tweak up clean-pkg-script #1048

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions scripts/clean-package-json.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

import fs from 'node:fs'
import path from 'node:path'
import { createRequire } from 'node:module'

const __dirname = path.dirname(new URL(import.meta.url).pathname)
const pkgJsonFile = path.join(__dirname, '../package.json')
const root = path.resolve(__dirname, '..')
const pkgJsonFile = path.join(root, 'package.json')
const _pkgJson = JSON.parse(fs.readFileSync(pkgJsonFile, 'utf-8'))

const whitelist = new Set([
'name',
Expand All @@ -41,9 +42,7 @@ const whitelist = new Set([
'license',
])

const _pkgJson = createRequire(import.meta.url)('../package.json')
const pkgJson = Object.fromEntries(
Object.entries(_pkgJson).filter(([k]) => whitelist.has(k))
)

fs.writeFileSync(pkgJsonFile, JSON.stringify(pkgJson, null, 2))
2 changes: 1 addition & 1 deletion test/export.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Google LLC
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Loading