-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: don't look for binaries using fs & walk (#51)
- Loading branch information
Showing
16 changed files
with
24 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,4 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import url from 'node:url'; | ||
|
||
/** | ||
* 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', | ||
); | ||
export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,4 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import url from 'node:url'; | ||
|
||
/** | ||
* 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', | ||
); | ||
export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,4 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import url from 'node:url'; | ||
|
||
/** | ||
* 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', | ||
); | ||
export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,4 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import url from 'node:url'; | ||
|
||
/** | ||
* 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', | ||
); | ||
export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,4 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import url from 'node:url'; | ||
|
||
/** | ||
* 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', | ||
); | ||
export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,4 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import url from 'node:url'; | ||
|
||
/** | ||
* 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', | ||
); | ||
export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,4 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import url from 'node:url'; | ||
|
||
/** | ||
* 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', | ||
); | ||
export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman.exe'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,4 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import url from 'node:url'; | ||
|
||
/** | ||
* 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', | ||
); | ||
export default path.join(url.fileURLToPath(new URL('.', import.meta.url)), 'chdman.exe'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters