title: Invoke packaged bash script from Node.js CLI using commander.js
body: <p>I am trying to write a CLI with <a href="https://github.com/tj/commander.js/" rel="nofollow noreferrer">commander.js</a>. I want to have a certain command in the CLI invoke a previously written bash script, as well as pass arguments to it. I know I can use <code>shell.exec()</code> for this like so inside &quot;<code>index.js</code>&quot;:</p>
  <pre class="lang-js prettyprint-override"><code>shellCommand = `./RunScripts/bashScript.sh ${options.option1} ${options.option2}`;
  if (shell.exec(shellCommand).code !== 0) {
      // ...do things
  }
  </code></pre>
  <p>This means I need to include the bash script with my package when I publish the CLI. Using <code>npm pack --dry-run</code>, I can see that the scripts do get included with the package. Here's a rough outline of the file system I have here:</p>
  <pre class="lang-sh prettyprint-override"><code>├── my-cli-directory
  │   ├── README.md
  │   └── RunScripts
  │      └── bashScript.sh
  │   ├── package.json
  │   └── index.js
  </code></pre>
  <p>When I publish my CLI and try to download it with <code>npm install ...</code> it gives me an error message that looks like this:</p>
  <pre class="lang-sh prettyprint-override"><code>/bin/sh: ./RunScripts/bashScript.sh: No such file or directory
  </code></pre>
  <p>This would make sense, as I am trying to tell <code>shell.exec</code> to run something that should be available at that location. Instead, <strong>how do I tell <code>shell.exec</code> to run the script packaged with my CLI?</strong></p>