Use readlink -f if realpath isn't available

This commit is contained in:
Asher 2019-08-19 16:59:36 -05:00
parent b4e1a62cb4
commit ce3b7dfb1e
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A

View File

@ -190,12 +190,21 @@ function binary-task() {
log "Binary: ${buildPath}/${binaryName}" log "Binary: ${buildPath}/${binaryName}"
} }
function absolute-path() {
local relative="${1}"; shift
if command -v realpath &> /dev/null ; then
realpath "${relative}"
else
readlink -f "${relative}"
fi
}
# Check if it looks like we are inside VS Code. # Check if it looks like we are inside VS Code.
function in-vscode () { function in-vscode () {
local dir="${1}" ; shift local dir="${1}" ; shift
local maybeVsCode local maybeVsCode
local dirName local dirName
maybeVsCode="$(realpath "${dir}/../../..")" maybeVsCode="$(absolute-path "${dir}/../../..")"
dirName="$(basename "${maybeVsCode}")" dirName="$(basename "${maybeVsCode}")"
if [[ "${dirName}" != "vscode" ]] ; then if [[ "${dirName}" != "vscode" ]] ; then
return 1 return 1
@ -213,7 +222,7 @@ function main() {
local relativeRootPath local relativeRootPath
local rootPath local rootPath
relativeRootPath="$(dirname "${0}")/.." relativeRootPath="$(dirname "${0}")/.."
rootPath="$(realpath "${relativeRootPath}")" rootPath="$(absolute-path "${relativeRootPath}")"
local task="${1}" ; shift local task="${1}" ; shift
if [[ "${task}" == "ensure-in-vscode" ]] ; then if [[ "${task}" == "ensure-in-vscode" ]] ; then