-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathtestutils.js
32 lines (27 loc) · 850 Bytes
/
testutils.js
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
const fs = require('fs')
const expressa = require('../')
const util = require('../util')
// See https://stackoverflow.com/questions/18052762/remove-directory-which-is-not-empty
const deleteFolderRecursive = function(path) {
if (fs.existsSync(path)) {
fs.readdirSync(path).forEach(function(file) {
const curPath = path + '/' + file
if (fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath)
} else { // delete file
fs.unlinkSync(curPath)
}
})
fs.rmdirSync(path)
}
}
deleteFolderRecursive('testdata')
fs.mkdirSync('testdata')
exports.api = expressa.api({
file_storage_path: 'testdata'
})
const express = require('express')
exports.app = express()
exports.app.use(exports.api)
exports.getUserWithPermissions = util.getUserWithPermissions
exports.clone = util.clone