Skip to content

Commit ce3b7df

Browse files
committed
Use readlink -f if realpath isn't available
1 parent b4e1a62 commit ce3b7df

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

scripts/tasks.bash

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,21 @@ function binary-task() {
190190
log "Binary: ${buildPath}/${binaryName}"
191191
}
192192

193+
function absolute-path() {
194+
local relative="${1}"; shift
195+
if command -v realpath &> /dev/null ; then
196+
realpath "${relative}"
197+
else
198+
readlink -f "${relative}"
199+
fi
200+
}
201+
193202
# Check if it looks like we are inside VS Code.
194203
function in-vscode () {
195204
local dir="${1}" ; shift
196205
local maybeVsCode
197206
local dirName
198-
maybeVsCode="$(realpath "${dir}/../../..")"
207+
maybeVsCode="$(absolute-path "${dir}/../../..")"
199208
dirName="$(basename "${maybeVsCode}")"
200209
if [[ "${dirName}" != "vscode" ]] ; then
201210
return 1
@@ -213,7 +222,7 @@ function main() {
213222
local relativeRootPath
214223
local rootPath
215224
relativeRootPath="$(dirname "${0}")/.."
216-
rootPath="$(realpath "${relativeRootPath}")"
225+
rootPath="$(absolute-path "${relativeRootPath}")"
217226

218227
local task="${1}" ; shift
219228
if [[ "${task}" == "ensure-in-vscode" ]] ; then

0 commit comments

Comments
 (0)