Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
  • Loading branch information
netlify-team-account-1 and eduardoboucas committed Nov 9, 2021
1 parent 4e2117b commit 562d669
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/runtimes/node/utils/package_json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const sanitiseFiles = (files: unknown): string[] | undefined => {
return files.filter((file) => typeof file === 'string')
}

const sanitisePackageJson = (pack: Record<string, unknown>): PackageJson => ({
...pack,
files: sanitiseFiles(pack.files),
const sanitisePackageJson = (packageJson: Record<string, unknown>): PackageJson => ({
...packageJson,
files: sanitiseFiles(packageJson.files),
})

// Retrieve the `package.json` of a specific project or module
Expand All @@ -39,8 +39,8 @@ const getPackageJson = async function (srcDir: string): Promise<PackageJson> {
try {
// The path depends on the user's build, i.e. must be dynamic
// eslint-disable-next-line import/no-dynamic-require, node/global-require, @typescript-eslint/no-var-requires
const pack = require(packageJsonPath)
return sanitisePackageJson(pack)
const packageJson = require(packageJsonPath)
return sanitisePackageJson(packageJson)
} catch (error) {
throw new Error(`${packageJsonPath} is invalid JSON: ${error.message}`)
}
Expand Down

0 comments on commit 562d669

Please sign in to comment.