Skip to content

Commit 41b3f79

Browse files
committed
add PATH tilde expansion
1 parent a4a263d commit 41b3f79

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

server/src/executables.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export default class Executables {
5959
* Only returns direct children, or the path itself if it's an executable.
6060
*/
6161
function findExecutablesInPath(path: string): Promise<string[]> {
62+
path = FsUtil.untildify(path)
6263
return new Promise((resolve, _) => {
6364
Fs.lstat(path, (err, stat) => {
6465
if (err) {

server/src/util/fs.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as Fs from 'fs'
2+
import * as Os from 'os'
23

34
export function getStats(path: string): Promise<Fs.Stats> {
45
return new Promise((resolve, reject) => {
@@ -11,3 +12,11 @@ export function getStats(path: string): Promise<Fs.Stats> {
1112
})
1213
})
1314
}
15+
16+
// from https://github.com/sindresorhus/untildify/blob/master/index.js#L11
17+
export function untildify(pathWithTilde: string): string {
18+
const homeDirectory = Os.homedir()
19+
return homeDirectory
20+
? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory)
21+
: pathWithTilde
22+
}

0 commit comments

Comments
 (0)