From a14a4bae35ec39e72bdefcf392970d7123913b53 Mon Sep 17 00:00:00 2001 From: Christian Emmer <10749361+emmercm@users.noreply.github.com> Date: Fri, 20 Sep 2024 20:58:54 -0700 Subject: [PATCH] CI: fix not finding the binary in another directory --- packages/chdman-darwin-arm64/.eslintrc | 3 +++ packages/chdman-darwin-arm64/index.ts | 23 ++++++++++++++++++++++- packages/chdman-darwin-arm64/package.json | 2 ++ packages/chdman-darwin-x64/.eslintrc | 3 +++ packages/chdman-darwin-x64/index.ts | 23 ++++++++++++++++++++++- packages/chdman-darwin-x64/package.json | 2 ++ packages/chdman-linux-arm/.eslintrc | 3 +++ packages/chdman-linux-arm/index.ts | 23 ++++++++++++++++++++++- packages/chdman-linux-arm/package.json | 2 ++ packages/chdman-linux-arm64/.eslintrc | 3 +++ packages/chdman-linux-arm64/index.ts | 23 ++++++++++++++++++++++- packages/chdman-linux-arm64/package.json | 2 ++ packages/chdman-linux-ia32/.eslintrc | 3 +++ packages/chdman-linux-ia32/index.ts | 23 ++++++++++++++++++++++- packages/chdman-linux-ia32/package.json | 2 ++ packages/chdman-linux-x64/.eslintrc | 3 +++ packages/chdman-linux-x64/index.ts | 23 ++++++++++++++++++++++- packages/chdman-linux-x64/package.json | 2 ++ packages/chdman-win32-ia32/.eslintrc | 3 +++ packages/chdman-win32-ia32/index.ts | 23 ++++++++++++++++++++++- packages/chdman-win32-ia32/package.json | 2 ++ packages/chdman-win32-x64/.eslintrc | 3 +++ packages/chdman-win32-x64/index.ts | 23 ++++++++++++++++++++++- packages/chdman-win32-x64/package.json | 2 ++ 24 files changed, 216 insertions(+), 8 deletions(-) create mode 100644 packages/chdman-darwin-arm64/.eslintrc create mode 100644 packages/chdman-darwin-x64/.eslintrc create mode 100644 packages/chdman-linux-arm/.eslintrc create mode 100644 packages/chdman-linux-arm64/.eslintrc create mode 100644 packages/chdman-linux-ia32/.eslintrc create mode 100644 packages/chdman-linux-x64/.eslintrc create mode 100644 packages/chdman-win32-ia32/.eslintrc create mode 100644 packages/chdman-win32-x64/.eslintrc diff --git a/packages/chdman-darwin-arm64/.eslintrc b/packages/chdman-darwin-arm64/.eslintrc new file mode 100644 index 0000000..b9233ee --- /dev/null +++ b/packages/chdman-darwin-arm64/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["../../.eslintrc"] +} diff --git a/packages/chdman-darwin-arm64/index.ts b/packages/chdman-darwin-arm64/index.ts index 8cf1f42..993336f 100644 --- a/packages/chdman-darwin-arm64/index.ts +++ b/packages/chdman-darwin-arm64/index.ts @@ -1,4 +1,25 @@ +import fs from 'node:fs'; import path from 'node:path'; import url from 'node:url'; -export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman'); +/** + * Search for a {@link fileName} in {@link filePath} or any of its parent directories. + */ +function scanUpPathForFile(filePath: string, fileName: string): string | undefined { + const fullPath = path.join(filePath, fileName); + if (fs.existsSync(fullPath)) { + return fullPath; + } + + const parentPath = path.dirname(filePath); + if (parentPath !== filePath) { + return scanUpPathForFile(path.dirname(filePath), fileName); + } + + return undefined; +} + +export default scanUpPathForFile( + url.fileURLToPath(new URL('.', import.meta.url)), + 'chdman', +); diff --git a/packages/chdman-darwin-arm64/package.json b/packages/chdman-darwin-arm64/package.json index d152f6a..35c9c54 100644 --- a/packages/chdman-darwin-arm64/package.json +++ b/packages/chdman-darwin-arm64/package.json @@ -20,6 +20,8 @@ }, "scripts": { "build": "tsc --build --verbose", + "lint": "eslint .", + "lint:fix": "eslint . --fix", "prepack": "npm run build && cp -f ../../LICENSE ../../README.md ./", "postpack": "rm ./LICENSE ./README.md" }, diff --git a/packages/chdman-darwin-x64/.eslintrc b/packages/chdman-darwin-x64/.eslintrc new file mode 100644 index 0000000..b9233ee --- /dev/null +++ b/packages/chdman-darwin-x64/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["../../.eslintrc"] +} diff --git a/packages/chdman-darwin-x64/index.ts b/packages/chdman-darwin-x64/index.ts index 8cf1f42..993336f 100644 --- a/packages/chdman-darwin-x64/index.ts +++ b/packages/chdman-darwin-x64/index.ts @@ -1,4 +1,25 @@ +import fs from 'node:fs'; import path from 'node:path'; import url from 'node:url'; -export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman'); +/** + * Search for a {@link fileName} in {@link filePath} or any of its parent directories. + */ +function scanUpPathForFile(filePath: string, fileName: string): string | undefined { + const fullPath = path.join(filePath, fileName); + if (fs.existsSync(fullPath)) { + return fullPath; + } + + const parentPath = path.dirname(filePath); + if (parentPath !== filePath) { + return scanUpPathForFile(path.dirname(filePath), fileName); + } + + return undefined; +} + +export default scanUpPathForFile( + url.fileURLToPath(new URL('.', import.meta.url)), + 'chdman', +); diff --git a/packages/chdman-darwin-x64/package.json b/packages/chdman-darwin-x64/package.json index db49e1c..57603ed 100644 --- a/packages/chdman-darwin-x64/package.json +++ b/packages/chdman-darwin-x64/package.json @@ -20,6 +20,8 @@ }, "scripts": { "build": "tsc --build --verbose", + "lint": "eslint .", + "lint:fix": "eslint . --fix", "prepack": "npm run build && cp -f ../../LICENSE ../../README.md ./", "postpack": "rm ./LICENSE ./README.md" }, diff --git a/packages/chdman-linux-arm/.eslintrc b/packages/chdman-linux-arm/.eslintrc new file mode 100644 index 0000000..b9233ee --- /dev/null +++ b/packages/chdman-linux-arm/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["../../.eslintrc"] +} diff --git a/packages/chdman-linux-arm/index.ts b/packages/chdman-linux-arm/index.ts index 8cf1f42..993336f 100644 --- a/packages/chdman-linux-arm/index.ts +++ b/packages/chdman-linux-arm/index.ts @@ -1,4 +1,25 @@ +import fs from 'node:fs'; import path from 'node:path'; import url from 'node:url'; -export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman'); +/** + * Search for a {@link fileName} in {@link filePath} or any of its parent directories. + */ +function scanUpPathForFile(filePath: string, fileName: string): string | undefined { + const fullPath = path.join(filePath, fileName); + if (fs.existsSync(fullPath)) { + return fullPath; + } + + const parentPath = path.dirname(filePath); + if (parentPath !== filePath) { + return scanUpPathForFile(path.dirname(filePath), fileName); + } + + return undefined; +} + +export default scanUpPathForFile( + url.fileURLToPath(new URL('.', import.meta.url)), + 'chdman', +); diff --git a/packages/chdman-linux-arm/package.json b/packages/chdman-linux-arm/package.json index 88a2815..68ebaca 100644 --- a/packages/chdman-linux-arm/package.json +++ b/packages/chdman-linux-arm/package.json @@ -20,6 +20,8 @@ }, "scripts": { "build": "tsc --build --verbose", + "lint": "eslint .", + "lint:fix": "eslint . --fix", "prepack": "npm run build && cp -f ../../LICENSE ../../README.md ./", "postpack": "rm ./LICENSE ./README.md" }, diff --git a/packages/chdman-linux-arm64/.eslintrc b/packages/chdman-linux-arm64/.eslintrc new file mode 100644 index 0000000..b9233ee --- /dev/null +++ b/packages/chdman-linux-arm64/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["../../.eslintrc"] +} diff --git a/packages/chdman-linux-arm64/index.ts b/packages/chdman-linux-arm64/index.ts index 8cf1f42..993336f 100644 --- a/packages/chdman-linux-arm64/index.ts +++ b/packages/chdman-linux-arm64/index.ts @@ -1,4 +1,25 @@ +import fs from 'node:fs'; import path from 'node:path'; import url from 'node:url'; -export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman'); +/** + * Search for a {@link fileName} in {@link filePath} or any of its parent directories. + */ +function scanUpPathForFile(filePath: string, fileName: string): string | undefined { + const fullPath = path.join(filePath, fileName); + if (fs.existsSync(fullPath)) { + return fullPath; + } + + const parentPath = path.dirname(filePath); + if (parentPath !== filePath) { + return scanUpPathForFile(path.dirname(filePath), fileName); + } + + return undefined; +} + +export default scanUpPathForFile( + url.fileURLToPath(new URL('.', import.meta.url)), + 'chdman', +); diff --git a/packages/chdman-linux-arm64/package.json b/packages/chdman-linux-arm64/package.json index d054fe9..d3dc18a 100644 --- a/packages/chdman-linux-arm64/package.json +++ b/packages/chdman-linux-arm64/package.json @@ -20,6 +20,8 @@ }, "scripts": { "build": "tsc --build --verbose", + "lint": "eslint .", + "lint:fix": "eslint . --fix", "prepack": "npm run build && cp -f ../../LICENSE ../../README.md ./", "postpack": "rm ./LICENSE ./README.md" }, diff --git a/packages/chdman-linux-ia32/.eslintrc b/packages/chdman-linux-ia32/.eslintrc new file mode 100644 index 0000000..b9233ee --- /dev/null +++ b/packages/chdman-linux-ia32/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["../../.eslintrc"] +} diff --git a/packages/chdman-linux-ia32/index.ts b/packages/chdman-linux-ia32/index.ts index 8cf1f42..993336f 100644 --- a/packages/chdman-linux-ia32/index.ts +++ b/packages/chdman-linux-ia32/index.ts @@ -1,4 +1,25 @@ +import fs from 'node:fs'; import path from 'node:path'; import url from 'node:url'; -export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman'); +/** + * Search for a {@link fileName} in {@link filePath} or any of its parent directories. + */ +function scanUpPathForFile(filePath: string, fileName: string): string | undefined { + const fullPath = path.join(filePath, fileName); + if (fs.existsSync(fullPath)) { + return fullPath; + } + + const parentPath = path.dirname(filePath); + if (parentPath !== filePath) { + return scanUpPathForFile(path.dirname(filePath), fileName); + } + + return undefined; +} + +export default scanUpPathForFile( + url.fileURLToPath(new URL('.', import.meta.url)), + 'chdman', +); diff --git a/packages/chdman-linux-ia32/package.json b/packages/chdman-linux-ia32/package.json index 9392715..8c86f8d 100644 --- a/packages/chdman-linux-ia32/package.json +++ b/packages/chdman-linux-ia32/package.json @@ -20,6 +20,8 @@ }, "scripts": { "build": "tsc --build --verbose", + "lint": "eslint .", + "lint:fix": "eslint . --fix", "prepack": "npm run build && cp -f ../../LICENSE ../../README.md ./", "postpack": "rm ./LICENSE ./README.md" }, diff --git a/packages/chdman-linux-x64/.eslintrc b/packages/chdman-linux-x64/.eslintrc new file mode 100644 index 0000000..b9233ee --- /dev/null +++ b/packages/chdman-linux-x64/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["../../.eslintrc"] +} diff --git a/packages/chdman-linux-x64/index.ts b/packages/chdman-linux-x64/index.ts index 8cf1f42..993336f 100644 --- a/packages/chdman-linux-x64/index.ts +++ b/packages/chdman-linux-x64/index.ts @@ -1,4 +1,25 @@ +import fs from 'node:fs'; import path from 'node:path'; import url from 'node:url'; -export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman'); +/** + * Search for a {@link fileName} in {@link filePath} or any of its parent directories. + */ +function scanUpPathForFile(filePath: string, fileName: string): string | undefined { + const fullPath = path.join(filePath, fileName); + if (fs.existsSync(fullPath)) { + return fullPath; + } + + const parentPath = path.dirname(filePath); + if (parentPath !== filePath) { + return scanUpPathForFile(path.dirname(filePath), fileName); + } + + return undefined; +} + +export default scanUpPathForFile( + url.fileURLToPath(new URL('.', import.meta.url)), + 'chdman', +); diff --git a/packages/chdman-linux-x64/package.json b/packages/chdman-linux-x64/package.json index 4c1efb2..33b4792 100644 --- a/packages/chdman-linux-x64/package.json +++ b/packages/chdman-linux-x64/package.json @@ -20,6 +20,8 @@ }, "scripts": { "build": "tsc --build --verbose", + "lint": "eslint .", + "lint:fix": "eslint . --fix", "prepack": "npm run build && cp -f ../../LICENSE ../../README.md ./", "postpack": "rm ./LICENSE ./README.md" }, diff --git a/packages/chdman-win32-ia32/.eslintrc b/packages/chdman-win32-ia32/.eslintrc new file mode 100644 index 0000000..b9233ee --- /dev/null +++ b/packages/chdman-win32-ia32/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["../../.eslintrc"] +} diff --git a/packages/chdman-win32-ia32/index.ts b/packages/chdman-win32-ia32/index.ts index d61c0ac..f9b9623 100644 --- a/packages/chdman-win32-ia32/index.ts +++ b/packages/chdman-win32-ia32/index.ts @@ -1,4 +1,25 @@ +import fs from 'node:fs'; import path from 'node:path'; import url from 'node:url'; -export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman.exe'); +/** + * Search for a {@link fileName} in {@link filePath} or any of its parent directories. + */ +function scanUpPathForFile(filePath: string, fileName: string): string | undefined { + const fullPath = path.join(filePath, fileName); + if (fs.existsSync(fullPath)) { + return fullPath; + } + + const parentPath = path.dirname(filePath); + if (parentPath !== filePath) { + return scanUpPathForFile(path.dirname(filePath), fileName); + } + + return undefined; +} + +export default scanUpPathForFile( + url.fileURLToPath(new URL('.', import.meta.url)), + 'chdman.exe', +); diff --git a/packages/chdman-win32-ia32/package.json b/packages/chdman-win32-ia32/package.json index ccf0a1b..1d41a37 100644 --- a/packages/chdman-win32-ia32/package.json +++ b/packages/chdman-win32-ia32/package.json @@ -20,6 +20,8 @@ }, "scripts": { "build": "tsc --build --verbose", + "lint": "eslint .", + "lint:fix": "eslint . --fix", "prepack": "npm run build && cp -f ../../LICENSE ../../README.md ./", "postpack": "rm ./LICENSE ./README.md" }, diff --git a/packages/chdman-win32-x64/.eslintrc b/packages/chdman-win32-x64/.eslintrc new file mode 100644 index 0000000..b9233ee --- /dev/null +++ b/packages/chdman-win32-x64/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["../../.eslintrc"] +} diff --git a/packages/chdman-win32-x64/index.ts b/packages/chdman-win32-x64/index.ts index d61c0ac..f9b9623 100644 --- a/packages/chdman-win32-x64/index.ts +++ b/packages/chdman-win32-x64/index.ts @@ -1,4 +1,25 @@ +import fs from 'node:fs'; import path from 'node:path'; import url from 'node:url'; -export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman.exe'); +/** + * Search for a {@link fileName} in {@link filePath} or any of its parent directories. + */ +function scanUpPathForFile(filePath: string, fileName: string): string | undefined { + const fullPath = path.join(filePath, fileName); + if (fs.existsSync(fullPath)) { + return fullPath; + } + + const parentPath = path.dirname(filePath); + if (parentPath !== filePath) { + return scanUpPathForFile(path.dirname(filePath), fileName); + } + + return undefined; +} + +export default scanUpPathForFile( + url.fileURLToPath(new URL('.', import.meta.url)), + 'chdman.exe', +); diff --git a/packages/chdman-win32-x64/package.json b/packages/chdman-win32-x64/package.json index 6556ea6..4bf8f32 100644 --- a/packages/chdman-win32-x64/package.json +++ b/packages/chdman-win32-x64/package.json @@ -20,6 +20,8 @@ }, "scripts": { "build": "tsc --build --verbose", + "lint": "eslint .", + "lint:fix": "eslint . --fix", "prepack": "npm run build && cp -f ../../LICENSE ../../README.md ./", "postpack": "rm ./LICENSE ./README.md" },