-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDownloadDocument_StandAlone.js
39 lines (28 loc) · 1.08 KB
/
DownloadDocument_StandAlone.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
33
34
35
36
37
38
39
const fs = require('fs')
const { resolve } = require('bluebird');
// récupère le nom du fichier de configuration
sFichierConfig = process.argv[2]
// Récupère la configuration du connecteur
stUnElement = JSON.parse(fs.readFileSync(sFichierConfig))
stParametres = {}
stParametres.secret = stUnElement.secrets
stOptions = {}
// Construit la structure avec les options
stOptions.COZY_URL = "https://localhost"
stOptions.fields = {}
stOptions.fields.login = stUnElement.login
stOptions.fields.password = stUnElement.password
stOptions.folder_to_save = stUnElement.folder_to_save
stOptions.fields.folderPath = stUnElement.folder_to_save
if (stUnElement.others)
{
stUnElement.others.forEach(stAddon => {
stOptions.fields[stAddon.name] = stAddon.value
});
}
process.env.COZY_PARAMETERS = JSON.stringify(stParametres)
process.env.COZY_FIELDS = JSON.stringify(stOptions)
// Importe le connecteur
require(stUnElement.source)
// Supprime le fichier
fs.unlinkSync(sFichierConfig)