-
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.
Fix FileSystemGitRepository>>commandExists: for Windows
Fixes #46.
- Loading branch information
Showing
2 changed files
with
11 additions
and
4 deletions.
There are no files selected for viewing
13 changes: 10 additions & 3 deletions
13
src/FileSystem-Git.package/FileSystemGitRepository.class/instance/commandExists..st
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,5 +1,12 @@ | ||
git porcelain - external | ||
commandExists: aString | ||
^ ((self osProcessClass: #ShellSyntax) new | ||
findExecutablePathFor: (aString copyUpTo: Character space) | ||
inDirectoryPath: nil) notNil | ||
| command pathDelimiter locations shellSyntax | | ||
command := aString copyUpTo: Character space. | ||
pathDelimiter := self osProcess isWindows ifTrue: [';'] ifFalse: [':']. | ||
locations := (self osProcess thisOSProcess path splitBy: pathDelimiter) | ||
collect: [:each | (FileSystem disk referenceTo: each) / command]. | ||
self osProcess isWindows ifTrue: [ | ||
locations := locations gather: [:each | {each. each withExtension: 'exe'}]]. | ||
shellSyntax := (self osProcessClass: #ShellSyntax) new. | ||
^ locations anySatisfy: [:each | | ||
each exists and: [shellSyntax isExecutable: each printString]] |
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