-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.js
More file actions
46 lines (43 loc) · 1.42 KB
/
setup.js
File metadata and controls
46 lines (43 loc) · 1.42 KB
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
40
41
42
43
44
45
46
//prompts for configuration setup
var inquirer = require('inquirer');
var fs = require('fs');
var path = require('path');
var dirname = path.normalize(__dirname + '/local/').replace(/\\/g, '/');
var configSetup = require('./bin/config-setup');
var questions = [{
type: 'input',
name: 'defaultDir',
default: dirname,
message: 'Enter the directory location where the local output \n and input files will be stored',
validate: function(v) {
if (!fs.existsSync(v)) return 'Does not exist.';
if (!fs.lstatSync(v).isDirectory()) return 'Not a directory.';
return true;
}
}, {
type: 'list',
name: 'logto',
message: 'Setup logging to',
choices: [{
name: 'Files',
value: 'file'
}, {
name: 'Console',
value: 'console'
}]
}];
inquirer.prompt(questions).then(function(a) {
var binds = (fs.existsSync('./config.json')) ? require('./config').defaultBindVars : {};
var config = configSetup(a.defaultDir, {
logto: a.logto,
defaultBindVars: binds
});
var v = config.valid();
if (v === true) {
var r = config.save();
if (r === true) return console.log('\nSaved config.\n\nIf you intend to connect to Oracle database, you can now:\n\n npm install oracledb\n\nFor more information on oracledb install see:\n https://github.com/psalmody/databridge/blob/master/INSTALL.md#oracle');
console.log(r.toString());
} else {
console.log('Weird... the config tester said:\n ' + v);
}
});