Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/src/executables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default class Executables {
* Only returns direct children, or the path itself if it's an executable.
*/
function findExecutablesInPath(path: string): Promise<string[]> {
path = FsUtil.untildify(path)
return new Promise((resolve, _) => {
Fs.lstat(path, (err, stat) => {
if (err) {
Expand Down
9 changes: 9 additions & 0 deletions server/src/util/fs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Fs from 'fs'
import * as Os from 'os'

export function getStats(path: string): Promise<Fs.Stats> {
return new Promise((resolve, reject) => {
Expand All @@ -11,3 +12,11 @@ export function getStats(path: string): Promise<Fs.Stats> {
})
})
}

// from https://github.com/sindresorhus/untildify/blob/f85a087418aeaa2beb56fe2684fe3b64fc8c588d/index.js#L11
export function untildify(pathWithTilde: string): string {
const homeDirectory = Os.homedir()
return homeDirectory
? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory)
: pathWithTilde
}