# fs-tree-json

> Represent directory tree with json or object.

Latest version **0.0.7** (published 2019-08-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install fs-tree-json
pnpm add fs-tree-json
yarn add fs-tree-json
bun add fs-tree-json
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2019-08-15 |
| First published | 2019-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 0 |
| Author | fixme199 |
| Maintainers | fixme199 |
| Keywords | tree, json, directory |

## Links

- npm: https://www.npmjs.com/package/fs-tree-json
- Repository: https://github.com/fixme199/tree
- Homepage: https://github.com/fixme199/tree#readme
- Issues: https://github.com/fixme199/tree/issues
- npm.io page: https://npm.io/package/fs-tree-json

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.7 (latest) — 2019-08-15
- 0.0.6 — 2019-08-14
- 0.0.5 — 2019-08-13
- 0.0.4 — 2019-08-13
- 0.0.3 — 2019-08-13
- 0.0.2 — 2019-08-13
- 0.0.1 — 2019-08-12

## README

# fs-tree-json 

## Introduction  
### Description  
Represent directory tree with json or object.

### Demo
<details>
<summary>for example. windows tree command.</summary>
<pre>
<code>
C:.
+---documents
|   |   a.txt
|   |   b.txt
|   |   c.txt
|   |
|   +---app
|   |       app_a.txt
|   |       app_b.txt
|   |       app_c.txt
|   |
|   +---music
|   \---video
+---downloads
|   |   a.exe
|   |   b.exe
|   |
|   \---test
|           test_a.exe
|           test_b.exe
|
\---favorites
</code>
</pre>
</details>

<details>
<summary>on the other hand this module.</summary>
<pre>
<code>
{
    "path": ".\\demo",
    "parent_path": ".",
    "filename": "demo",
    "extension": "",
    "is_directory": true,
    "children": [
        {
            "path": ".\\demo\\documents",
            "parent_path": ".\\demo",
            "filename": "documents",
            "extension": "",
            "is_directory": true,
            "children": [
                {
                    "path": ".\\demo\\documents\\a.txt",
                    "parent_path": ".\\demo\\documents",
                    "filename": "a.txt",
                    "extension": ".txt",
                    "is_directory": false,
                    "children": []
                },
                {
                    "path": ".\\demo\\documents\\app",
                    "parent_path": ".\\demo\\documents",
                    "filename": "app",
                    "extension": "",
                    "is_directory": true,
                    "children": [
                        {
                            "path": ".\\demo\\documents\\app\\app_a.txt",
                            "parent_path": ".\\demo\\documents\\app",
                            "filename": "app_a.txt",
                            "extension": ".txt",
                            "is_directory": false,
                            "children": []
                        },
                        {
                            "path": ".\\demo\\documents\\app\\app_b.txt",
                            "parent_path": ".\\demo\\documents\\app",
                            "filename": "app_b.txt",
                            "extension": ".txt",
                            "is_directory": false,
                            "children": []
                        },
                        {
                            "path": ".\\demo\\documents\\app\\app_c.txt",
                            "parent_path": ".\\demo\\documents\\app",
                            "filename": "app_c.txt",
                            "extension": ".txt",
                            "is_directory": false,
                            "children": []
                        }
                    ]
                },
                {
                    "path": ".\\demo\\documents\\b.txt",
                    "parent_path": ".\\demo\\documents",
                    "filename": "b.txt",
                    "extension": ".txt",
                    "is_directory": false,
                    "children": []
                },
                {
                    "path": ".\\demo\\documents\\c.txt",
                    "parent_path": ".\\demo\\documents",
                    "filename": "c.txt",
                    "extension": ".txt",
                    "is_directory": false,
                    "children": []
                },
                {
                    "path": ".\\demo\\documents\\music",
                    "parent_path": ".\\demo\\documents",
                    "filename": "music",
                    "extension": "",
                    "is_directory": true,
                    "children": []
                },
                {
                    "path": ".\\demo\\documents\\video",
                    "parent_path": ".\\demo\\documents",
                    "filename": "video",
                    "extension": "",
                    "is_directory": true,
                    "children": []
                }
            ]
        },
        {
            "path": ".\\demo\\downloads",
            "parent_path": ".\\demo",
            "filename": "downloads",
            "extension": "",
            "is_directory": true,
            "children": [
                {
                    "path": ".\\demo\\downloads\\a.exe",
                    "parent_path": ".\\demo\\downloads",
                    "filename": "a.exe",
                    "extension": ".exe",
                    "is_directory": false,
                    "children": []
                },
                {
                    "path": ".\\demo\\downloads\\b.exe",
                    "parent_path": ".\\demo\\downloads",
                    "filename": "b.exe",
                    "extension": ".exe",
                    "is_directory": false,
                    "children": []
                },
                {
                    "path": ".\\demo\\downloads\\test",
                    "parent_path": ".\\demo\\downloads",
                    "filename": "test",
                    "extension": "",
                    "is_directory": true,
                    "children": [
                        {
                            "path": ".\\demo\\downloads\\test\\test_a.exe",
                            "parent_path": ".\\demo\\downloads\\test",
                            "filename": "test_a.exe",
                            "extension": ".exe",
                            "is_directory": false,
                            "children": []
                        },
                        {
                            "path": ".\\demo\\downloads\\test\\test_b.exe",
                            "parent_path": ".\\demo\\downloads\\test",
                            "filename": "test_b.exe",
                            "extension": ".exe",
                            "is_directory": false,
                            "children": []
                        }
                    ]
                }
            ]
        },
        {
            "path": ".\\demo\\favorites",
            "parent_path": ".\\demo",
            "filename": "favorites",
            "extension": "",
            "is_directory": true,
            "children": []
        }
    ]
}
</code>
</pre>
</details>

## How to use  
### Install  
```
npm i fs-tree-json
```

### Usage  
```
const { tree, treeSync } = require('fs-tree-json');
// async need callback.
tree('.', (result) => {
    console.log(result); // return object only.
});
tree('.', './output.json', (result) => {
    console.log(result); // and output json.
});
// sync slightly faster than async function.
const syncObject = treeSync('.'); // return object only.
const syncJson = treeSync('.', './output.json'); // and output json.
```

## Develop  
### Linux 環境準備 
`aurman -S python2`  
`which python2`  
`npm config set python /usr/bin/python2`  

`% gcc --version`  
`gcc (GCC) 9.1.0`  
`% g++ --version`  
`g++ (GCC) 9.1.0`

### Windows環境準備 
#### インストール 
`npm i -g windows-build-tools`  

##### Visual Studio Build Tools 2017  
##### python 2.7  

#### npm config 
`npm config set msvs_version 2017`  
`npm config set python "C:\Python27\python.exe"`  

### node-gyp 実行
`npm i`  
`npm rebuild node-gyp`  
`npm run build`  
`npm run test`

---
_Source: https://npm.io/package/fs-tree-json · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
