title: How to export local folder structure with nodeJS?
body: <p>Reading directories recursivly is not the problem. There are many good libraries for it, for instance <a href="https://github.com/jergason/recursive-readdir" rel="nofollow noreferrer">recursive-readdir</a>.</p>
  
  <p>I am searching for a solution to extract <strong>only</strong> the folder structure without any files etc.</p>
  
  <p><strong>Example folder structure:</strong></p>
  
  <pre><code>src/app/_content
  ├── contact.md
  ├── disclaimer.md
  ├── imprint.md
  ├── index.md
  ├── news.md
  ├── vita.md
  └── work
      ├── drawing
      │   └── Z-WV-2018-001
      │       ├── index.md
      │       └── Z-WV-2018-001-0.jpeg
      └── sculpture
          └── EMPTY DIRECTORY
  </code></pre>
  
  <p>The <strong>wished output</strong> is an array like that:</p>
  
  <pre><code>const dirs = [
    'work',
    'work/drawing',
    'work/sculpture'
  ]
  </code></pre>
  
  <hr>
  
  <h2><strong>Further Information:</strong> The following part is not explicitly part of that question. This will be an additional part for a better understand of the problem deep in the back of my brain.</h2>
  
  <p>This should not be that hard, but in addition I will need to extract in the second step an object like this:</p>
  
  <pre><code>const files = [
    'content.md',
    'disclaimer.md',
    'imprint.md',
    'index.md',
    'news.md',
    'vita.md',
    {
      'work': [
        {
          'drawing': [
            {
              'Z-WV-2018-001': [
                'index.md',
                'Z-WV-2018-001-0.jpeg'
              ],
            },
            {
              'sculpture': []
            }
          ]
        }
      ]
    }
  ]
  </code></pre>
  
  <p><code>dirs</code> will be needed for a browser application to know the pathes to the files. <code>files</code> will be neded to get the corresponding files out of the directories. </p>
  
  <p><em>For clarification, I am building a static page generator with Angular 6 and it is not possible to read client-sidely the folder structure. Therefore it is necessary to compile that structure and put it with an nodejs script into the published folder. So Angular will know where to look for that files.</em></p>
  
  <p>Please write a comment, if you need more clarification. I just wanted to be exact as possible. </p>