Skip to content

Commit fde973c

Browse files
committed
Update scripts
1 parent a8e9d9b commit fde973c

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

scripts/lib/templates.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { PackageURL } = require('@socketregistry/packageurl-js')
1010
const constants = require('@socketregistry/scripts/constants')
1111
const { getManifestData } = require('@socketsecurity/registry')
1212
const { joinAnd } = require('@socketsecurity/registry/lib/arrays')
13-
const { globLicenses } = require('@socketsecurity/registry/lib/globs')
13+
const { globStreamLicenses } = require('@socketsecurity/registry/lib/globs')
1414
const { isObjectObject } = require('@socketsecurity/registry/lib/objects')
1515
const {
1616
readPackageJson,
@@ -72,7 +72,9 @@ async function getLicenseActions(pkgPath) {
7272
license: LICENSE_CONTENT
7373
}
7474
const actions = []
75-
for (const filepath of await globLicenses(pkgPath, { recursive: true })) {
75+
for (const filepath of await globStreamLicenses(pkgPath, {
76+
recursive: true
77+
})) {
7678
actions.push([filepath, licenseData])
7779
}
7880
return actions

scripts/update-licenses.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33
const fs = require('node:fs/promises')
44

55
const constants = require('@socketregistry/scripts/constants')
6-
const { globLicenses } = require('@socketsecurity/registry/lib/globs')
6+
const { globStreamLicenses } = require('@socketsecurity/registry/lib/globs')
7+
const { transform } = require('@socketsecurity/registry/lib/streams')
78

89
const { LICENSE, LICENSE_CONTENT, UTF8, ignoreGlobs, rootPath } = constants
910

1011
void (async () => {
11-
await Promise.all(
12-
(
13-
await globLicenses(rootPath, {
14-
recursive: true,
15-
ignoreOriginals: true,
16-
ignore: [LICENSE, 'scripts/templates', ...ignoreGlobs]
17-
})
18-
).map(licensePath => fs.writeFile(licensePath, LICENSE_CONTENT, UTF8))
19-
)
12+
const stream = await globStreamLicenses(rootPath, {
13+
recursive: true,
14+
ignoreOriginals: true,
15+
ignore: [LICENSE, 'scripts/templates', ...ignoreGlobs]
16+
})
17+
18+
for await (const licensePath of transform(
19+
8, // Concurrency level.
20+
async filepath => filepath,
21+
stream
22+
)) {
23+
fs.writeFile(licensePath, LICENSE_CONTENT, UTF8)
24+
}
2025
})()

0 commit comments

Comments
 (0)