diff --git a/utils/create-symlink/create-symlink.js b/utils/create-symlink/create-symlink.js index 13e324f588..fef20bba5b 100644 --- a/utils/create-symlink/create-symlink.js +++ b/utils/create-symlink/create-symlink.js @@ -29,18 +29,19 @@ function createSymbolicLink(src, dest, type) { .then(() => fs.symlink(src, dest, type)); } -function createPosixSymlink(origin, dest, _type) { +function createPosixSymlink(src, dest, _type) { const type = _type === "exec" ? "file" : _type; - const relativeSymlink = path.relative(path.dirname(dest), origin); + const relativeSymlink = path.relative(path.dirname(dest), src); if (_type === "exec") { - // If the target exists, create real symlink. If the target doesn't exist yet, - // create a shim shell script. - return fs.pathExists(origin).then(exists => { + // If the src exists, create a real symlink. + // If the src doesn't exist yet, create a shim shell script. + return fs.pathExists(src).then(exists => { if (exists) { - return createSymbolicLink(relativeSymlink, dest, type).then(() => fs.chmod(origin, "755")); + return createSymbolicLink(relativeSymlink, dest, type).then(() => fs.chmod(src, "755")); } - return shShim(origin, dest, type).then(() => fs.chmod(dest, "755")); + + return shShim(src, dest, type).then(() => fs.chmod(dest, "755")); }); } @@ -55,12 +56,11 @@ function createWindowsSymlink(src, dest, type) { return createSymbolicLink(src, dest, type); } -function shShim(target, script, type) { - log.silly("shShim", [target, script, type]); - - const absTarget = path.resolve(path.dirname(script), target); +function shShim(src, dest, type) { + log.silly("shShim", [src, dest, type]); + const absTarget = path.resolve(path.dirname(dest), src); const scriptLines = ["#!/bin/sh", `chmod +x ${absTarget} && exec ${absTarget} "$@"`]; - return fs.writeFile(script, scriptLines.join("\n")); + return fs.writeFile(dest, scriptLines.join("\n")); }