Skip to content

Commit

Permalink
Merge branch 'main' into feat/tools-as-components
Browse files Browse the repository at this point in the history
  • Loading branch information
jkowalleck authored Jan 9, 2025
2 parents 899cae3 + b93b1c3 commit f75110c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
import { readFileSync, writeSync } from 'fs'
import { extname, parse } from 'path'

export const structuredClonePolyfill: <T>(value: T) => T = typeof structuredClone === 'function'
? structuredClone
: function (value) { return JSON.parse(JSON.stringify(value)) }

export function loadJsonFile (path: string): any {
return JSON.parse(readFileSync(path, 'utf8'))
// may be replaced by `require(f, { with: { type: "json" } })`
Expand Down
12 changes: 7 additions & 5 deletions src/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ import * as normalizePackageData from 'normalize-package-data'
import * as path from 'path'
import { join } from 'path'

import { getMimeForLicenseFile, isString, loadJsonFile, tryRemoveSecretsFromUrl } from './_helpers'
import {
getMimeForLicenseFile,
isString,
loadJsonFile,
structuredClonePolyfill,
tryRemoveSecretsFromUrl
} from './_helpers'
import { makeNpmRunner, type runFunc } from './npmRunner'
import { PropertyNames, PropertyValueBool } from './properties'
import { versionCompare } from './versionCompare'
Expand Down Expand Up @@ -713,7 +719,3 @@ export class TreeBuilder {
}
}
}

const structuredClonePolyfill: <T>(value: T) => T = typeof structuredClone === 'function'
? structuredClone
: function (value) { return JSON.parse(JSON.stringify(value)) }

0 comments on commit f75110c

Please sign in to comment.