title: How to run bash scripts with yarn via a separate file?
body: <p>I have a Node/React project and in my <strong>package.json</strong> if I want to run some simple scripts I might do something like this:</p>
  
  <pre><code>{
    "scripts": {
      "prep": "cp -r this/sub-directory/path another/sub-directory/path"
    },
  }
  </code></pre>
  
  <p>And then <code>yarn prep</code> to execute it.</p>
  
  <p>However in this case I have a lot of commands, say 5-6 and to put them all on one line in a package.json file would make it difficult to read.</p>
  
  <p>What I would like to do is put them in a separate file and then just call that file. Something like a file named <strong>run-script</strong>:</p>
  
  <pre><code>#!/bin/bash
  
  echo 'test'
  </code></pre>
  
  <p>and then in package.json:</p>
  
  <pre><code>{
    "scripts": {
      "prep": "run-script"
    },
  }
  </code></pre>
  
  <p>But that gives me errors obviously, I don't know how to tell it to run the file, what extension it should be, etc. (I'm aware that I can do <code>"prep": "node run-script.js"</code> but in this case I want to do simple things like copy directories and such, not JavaScript things.)</p>
  
  <hr>
  
  <h3>Update [SOLVED]</h3>
  
  <p>Both of <a href="https://stackoverflow.com/users/2849202/roadowl">@roadowl</a>’s solutions were needed.</p>
  
  <ol>
  <li>Run <code>chmod ug+x run-script</code> to set the permissions, and then</li>
  <li>Add the current working directory variable (<code>$PWD</code>) in front of where the file is called in <strong>package.json</strong>:</li>
  </ol>
  
  <pre><code>{
    "scripts": {
      "prep": "$PWD/run-script"
    },
  }
  </code></pre>