From c799408d0d009a2fc8127f580e97736bb06132e2 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Thu, 9 Sep 2021 10:47:56 -0600 Subject: [PATCH] fix: use absolute path to sf bin --- bin/run-sf | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/run-sf b/bin/run-sf index a7ede371..7307d21e 100755 --- a/bin/run-sf +++ b/bin/run-sf @@ -3,6 +3,13 @@ const cp = require('child_process'); const path = require('path'); -const sfPath = path.join('node_modules', '.bin', 'sf') +function trimUntil(fsPath, part) { + const parts = fsPath.split(path.sep); + const partIndex = parts.findIndex((p) => part === p); + if (partIndex === -1) return fsPath; + return parts.slice(0, partIndex + 1).join(path.sep); +} -cp.spawn(sfPath, process.argv.slice(2), { stdio: 'inherit' }) +const modulePath = require.resolve('@salesforce/cli'); +const sfPath = path.join(trimUntil(modulePath, 'cli'), 'bin', 'run'); +cp.spawn(sfPath, process.argv.slice(2), { stdio: 'inherit' });