Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
fix: create path before moving sf to it
Browse files Browse the repository at this point in the history
  • Loading branch information
RodEsp committed Oct 7, 2021
1 parent b408631 commit 7764405
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions scripts/include-sf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@ const shelljs = require('shelljs');
const fs = require('fs');

try {
const sfGlobalPath = path.join(shelljs.exec('npm list -g --depth 0 | head -1').stdout, 'node_modules', '@salesforce', 'cli');
const sfGlobalPath = path.join(
shelljs.exec('npm list -g --depth 0 | head -1').stdout,
'node_modules',
'@salesforce',
'cli'
);

// Copy sf to the bin/cli dir of sfdx
shelljs.mv('-f', sfGlobalPath, path.join(process.cwd(), 'bin', 'sf-cli'));
const sfpath = path.join(process.cwd(), 'sf-cli');
shelljs.mkdir('-p', sfpath);
shelljs.mv('-f', sfGlobalPath, 'sf-cli');
} catch (e) {
console.error('Error: can\'t find the global sf install.')
console.error("Error: can't find the global sf install.");
throw e;
}

const sfUnixPath = 'bin/sf-cli/bin/run';
const sfUnixPath = 'sf-cli/bin/run';
const sfBin = path.join('bin', 'sf');
const sfdxBin = path.join('bin', 'sfdx');

Expand All @@ -24,13 +31,13 @@ const binContents = fs
.readFileSync(sfdxBin, 'UTF-8')
.replace(/sfdx/g, 'sf')
.replace(/SFDX/g, 'SF')
.replace(/\$DIR\/run/g, `$(dirname $DIR)/${sfUnixPath}`);
.replace(/\$DIR\/run/g, sfUnixPath);

console.log(` Writing ${sfBin}`);
fs.writeFileSync(sfBin, binContents);
shelljs.chmod('+x', sfBin);

const sfWinPath = 'bin\\sf-cli\\bin\\run';
const sfWinPath = 'sf-cli\\bin\\run';
const sfCmd = path.join('bin', 'sf.cmd');
const sfdxCmd = path.join('bin', 'sfdx.cmd');

Expand Down

0 comments on commit 7764405

Please sign in to comment.