This repository was archived by the owner on Dec 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,13 @@ public abstract function getCurrentUser();
40
40
/** @return string */
41
41
public abstract function getCurrentUserHome ();
42
42
43
- /** @return string */
43
+ /**
44
+ * @param string $cmdName
45
+ * @return boolean
46
+ */
47
+ public abstract function checkIfCommandExists ($ cmdName );
48
+
49
+ /** @return string */
44
50
public abstract function getAppDataDirectory ();
45
51
46
52
/**
Original file line number Diff line number Diff line change @@ -32,6 +32,24 @@ public function getCurrentUserHome()
32
32
}
33
33
}
34
34
35
+ /**
36
+ * @param string $cmdName
37
+ * @return boolean
38
+ */
39
+ public function checkIfCommandExists ($ cmdName )
40
+ {
41
+ if (!function_exists ('exec ' )) {
42
+ return false ;
43
+ }
44
+
45
+ $ sysResponse = exec (
46
+ 'PATH= ' .getenv ('PATH ' ).'; ' .
47
+ "if command -v " .$ cmdName ." >/dev/null 2>&1; then echo \"true \"; else echo \"false \"; fi; "
48
+ );
49
+
50
+ return filter_var ($ sysResponse , FILTER_VALIDATE_BOOLEAN , FILTER_NULL_ON_FAILURE );
51
+ }
52
+
35
53
/**
36
54
* Returns true if the path is a "valid" path and is writable (even if the complete path does not yet exist).
37
55
* @param string $path
You can’t perform that action at this time.
0 commit comments