Skip to content

Commit cbeeff4

Browse files
committed
Make .env optional
1 parent 741448e commit cbeeff4

File tree

5 files changed

+36
-23
lines changed

5 files changed

+36
-23
lines changed

.prettierignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

.prettierrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"useTabs": true,
44
"printWidth": 120,
55
"semi": false,
6-
"bracketSameLine": true
6+
"bracketSameLine": true,
7+
"ignore": ["node_modules", "dist", "build", "out", ".next", ".venv", "pnpm-lock.yaml"]
78
}

apps/vscode-nightly/esbuild.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ async function main() {
6767
["../README.md", "README.md"],
6868
["../CHANGELOG.md", "CHANGELOG.md"],
6969
["../LICENSE", "LICENSE"],
70+
["../.env", ".env", { optional: true }],
7071
[".vscodeignore", ".vscodeignore"],
7172
["assets", "assets"],
7273
["integrations", "integrations"],

packages/build/src/esbuild.ts

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ function rmDir(dirPath: string, maxRetries: number = 3): void {
2929
return
3030
} catch (error) {
3131
const isLastAttempt = attempt === maxRetries
32-
const isEnotemptyError = error instanceof Error && "code" in error && (error.code === 'ENOTEMPTY' || error.code === 'EBUSY')
32+
33+
const isEnotemptyError =
34+
error instanceof Error && "code" in error && (error.code === "ENOTEMPTY" || error.code === "EBUSY")
3335

3436
if (isLastAttempt || !isEnotemptyError) {
3537
throw error // Re-throw if it's the last attempt or not a locking error.
@@ -41,27 +43,42 @@ function rmDir(dirPath: string, maxRetries: number = 3): void {
4143

4244
// Synchronous sleep for simplicity in build scripts.
4345
const start = Date.now()
44-
while (Date.now() - start < delay) { /* Busy wait */ }
46+
47+
while (Date.now() - start < delay) {
48+
/* Busy wait */
49+
}
4550
}
4651
}
4752
}
4853

49-
export function copyPaths(copyPaths: [string, string][], srcDir: string, dstDir: string) {
50-
copyPaths.forEach(([srcRelPath, dstRelPath]) => {
51-
const stats = fs.lstatSync(path.join(srcDir, srcRelPath))
54+
type CopyPathOptions = {
55+
optional?: boolean
56+
}
5257

53-
if (stats.isDirectory()) {
54-
if (fs.existsSync(path.join(dstDir, dstRelPath))) {
55-
rmDir(path.join(dstDir, dstRelPath))
56-
}
58+
export function copyPaths(copyPaths: [string, string, CopyPathOptions?][], srcDir: string, dstDir: string) {
59+
copyPaths.forEach(([srcRelPath, dstRelPath, options = {}]) => {
60+
try {
61+
const stats = fs.lstatSync(path.join(srcDir, srcRelPath))
5762

58-
fs.mkdirSync(path.join(dstDir, dstRelPath), { recursive: true })
63+
if (stats.isDirectory()) {
64+
if (fs.existsSync(path.join(dstDir, dstRelPath))) {
65+
rmDir(path.join(dstDir, dstRelPath))
66+
}
5967

60-
const count = copyDir(path.join(srcDir, srcRelPath), path.join(dstDir, dstRelPath), 0)
61-
console.log(`[copyPaths] Copied ${count} files from ${srcRelPath} to ${dstRelPath}`)
62-
} else {
63-
fs.copyFileSync(path.join(srcDir, srcRelPath), path.join(dstDir, dstRelPath))
64-
console.log(`[copyPaths] Copied ${srcRelPath} to ${dstRelPath}`)
68+
fs.mkdirSync(path.join(dstDir, dstRelPath), { recursive: true })
69+
70+
const count = copyDir(path.join(srcDir, srcRelPath), path.join(dstDir, dstRelPath), 0)
71+
console.log(`[copyPaths] Copied ${count} files from ${srcRelPath} to ${dstRelPath}`)
72+
} else {
73+
fs.copyFileSync(path.join(srcDir, srcRelPath), path.join(dstDir, dstRelPath))
74+
console.log(`[copyPaths] Copied ${srcRelPath} to ${dstRelPath}`)
75+
}
76+
} catch (error) {
77+
if (options.optional) {
78+
console.warn(`[copyPaths] Optional file not found: ${srcRelPath}`)
79+
} else {
80+
throw error
81+
}
6582
}
6683
})
6784
}

src/esbuild.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async function main() {
5252
["../README.md", "README.md"],
5353
["../CHANGELOG.md", "CHANGELOG.md"],
5454
["../LICENSE", "LICENSE"],
55-
["../.env", ".env"],
55+
["../.env", ".env", { optional: true }],
5656
["node_modules/vscode-material-icons/generated", "assets/vscode-material-icons"],
5757
["../webview-ui/audio", "webview-ui/audio"],
5858
],

0 commit comments

Comments
 (0)