Skip to content

Commit 7bcd197

Browse files
committed
Replace find command with fs operations for generator cleanup
Use `fs.readdirSync` and `fs.rmSync` instead of `child_process.execFileSync` with `find` command for better maintainability and cross-platform compatibility
1 parent 23010ac commit 7bcd197

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

build/package-generators/curlconverter.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const path = require('path')
77
const buildDir = execEnv.buildDir
88
const packageJsonPath = path.join(buildDir, 'package.json')
99
const packageLockPath = path.join(buildDir, 'package-lock.json')
10+
const generatorsDir = path.join(buildDir, 'src', 'generators')
1011

1112
const projectDir = process.env.PROJECT_CWD
1213
const tarballPath = path.join(
@@ -51,11 +52,11 @@ child_process.execFileSync(
5152
fs.cpSync(packageLockSourcePath, packageLockPath)
5253

5354
// Remove all generators except json
54-
child_process.execFileSync(
55-
'find',
56-
['-not', '-name', 'json.ts', '-path', './src/generators/*', '-delete'],
57-
{ cwd: buildDir },
58-
)
55+
for (const file of fs.readdirSync(generatorsDir)) {
56+
if (file !== 'json.ts') {
57+
fs.rmSync(path.join(generatorsDir, file), { recursive: true, force: true })
58+
}
59+
}
5960
fs.writeFileSync(
6061
path.join(buildDir, 'src/index.ts'),
6162
'export { toJsonString } from "./generators/json.js";',

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ __metadata:
16931693

16941694
"curlconverter@exec:build/package-generators/curlconverter.js::locator=HackBar%40workspace%3A.":
16951695
version: 4.11.0
1696-
resolution: "curlconverter@exec:build/package-generators/curlconverter.js#build/package-generators/curlconverter.js::hash=513541&locator=HackBar%40workspace%3A."
1696+
resolution: "curlconverter@exec:build/package-generators/curlconverter.js#build/package-generators/curlconverter.js::hash=982dc7&locator=HackBar%40workspace%3A."
16971697
dependencies:
16981698
jsesc: "npm:^3.0.2"
16991699
lossless-json: "npm:^4.0.2"
@@ -1702,7 +1702,7 @@ __metadata:
17021702
tree-sitter-bash: "npm:^0.23.1"
17031703
web-tree-sitter: "npm:^0.24.3"
17041704
yamljs: "npm:^0.3.0"
1705-
checksum: 10c0/92243714b9377c725b48a64f5e4d63f5f37e68b67ab38677bb72a57607d5ff36d47a0ffe462a4e4b399faa902e0e807e996d92e59f9e334de717fbbc805be69d
1705+
checksum: 10c0/a63e24fff5da2d3ad756d886d63d8ee0107f1dd49c4be83ef7506bac38bb63084ddc86d4dccb6514c479e3aea2daf8de1535a5c42af8806d64f2ca90ecf34fbe
17061706
languageName: node
17071707
linkType: hard
17081708

0 commit comments

Comments
 (0)