title: Find and merge all package.json files into one using jq in bash?
body: <p>How can I find all <code>package.json</code> files and merge them into one file using <code>jq</code> within Bash?  The following snippet is as far as I have gotten, however it <strong>appends</strong> the files:</p>
  
  <pre><code>find ../../projects -maxdepth 4 -type f -name "package.json" \
    -exec cat {} + | jq -s . &gt; $(CURDIR)/node/.tmp/package.json
  </code></pre>
  
  <p>I have tried using 'add' but that seems to overwrite the target each time without merging the two.</p>
  
  <p>My project structure <strong>initially</strong> looks like this:</p>
  
  <pre><code>\ projects
    \ webapp
       \ package.json
    \ service
       \ package.json
    \ admin
       \ package.json
  \ solutions
    \ killersolution
         Makefile
       \ node
  </code></pre>
  
  <p>And <strong>should</strong> look like this after <code>make prenode</code> (see below):</p>
  
  <pre><code>\ projects
    \ webapp
       \ package.json
    \ service
       \ package.json
    \ admin
       \ package.json
  \ solutions
    \ killersolution
         Makefile
       \ node
          \ .tmp
            \ package.json   &lt;- created
  </code></pre>
  
  <p>I am using a <code>Makefile</code> to kick this off:</p>
  
  <pre><code>prenode:                                                                 
    @find ./node -type d -name ".tmp" -exec rm -rf {} +;                 
    @mkdir -p ./node/.tmp                                                
    @find ../../solutions -maxdepth 4 -type f -name "package.json" -exec cat {} + ... 
  </code></pre>
  
  <p><strong>Edit #1 : Example Input &amp; Output</strong><br>
  Let us assume 3 <code>package.json</code> files were found.  The <code>dependencies</code> and <code>devDependencies</code> are different but must be combined:</p>
  
  <p>Found file #1 ...</p>
  
  <pre><code>{
    "name":"project-a",
    "dependencies":{
      "module-a":"1.2.3"
    }
  }
  </code></pre>
  
  <p>Found file #2 ...</p>
  
  <pre><code>{
    "name":"project-b",
    "dependencies":{
      "module-b":"2.3.4"
    }
  }
  </code></pre>
  
  <p>Found file #3 ...  </p>
  
  <pre><code>{
    "name":"project-c",
    "devDependencies":{
      "gulp":"*"
    }
  }
  </code></pre>
  
  <p>... would all be combined to make the following file:</p>
  
  <pre><code>{
    "name":"project-c",
    "dependencies":{
      "module-a":"1.2.3",
      "module-b":"2.3.4"
    },
    "devDependencies":{
      "gulp":"*"
    }
  }
  </code></pre>
  
  <p>*Note: 
  The <code>name</code> property, in the final output file, is irrelevant.  The key here is the merge of the <code>dependencies</code> and <code>devDependencies</code> objects.</p>