-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (30 loc) · 744 Bytes
/
index.js
File metadata and controls
36 lines (30 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// @author laudeon
// MIT licensed
'use strict'
require('dotenv').config()
const fs = require('fs')
const path = require('path')
const debug = require('debug')('drive-list-folder')
const app = require('./lib')
const {getTree} = require('./lib/tree')
const tree = (params) => {
return app.vroum(params)
.then(res => getTree(res.files))
.catch(debug)
}
const treeToFile = (params, path) => {
return app.vroum(params)
.then(res => {
const tree = getTree(res.files)
const data = JSON.stringify(tree)
fs.writeFile(path, data, 'UTF-8', err => {
if (err) throw err
debug('tree saved in json file!')
})
})
.catch(debug)
}
module.exports = {
tree: tree,
treeToFile: treeToFile
}