Browse Source

allow seed data

Kieran Gibb 2 years ago
parent
commit
e343296396
No known key found for this signature in database
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      index.js

+ 3
- 3
index.js View File

@@ -7,7 +7,7 @@ const logger = require('./logger')
7 7
 
8 8
 const CONFIG_FILE = 'config.yml'
9 9
 
10
-module.exports = (storage) => new CoBoxConfig(storage)
10
+module.exports = (storage, opts) => new CoBoxConfig(storage, opts)
11 11
 
12 12
 const KeyHandler = require('./lib/key-handler')
13 13
 const MapHandler = require('./lib/map-handler')
@@ -26,7 +26,7 @@ const defaultConfig = () => ({
26 26
 const logfile = [new Date().toISOString().replace(/:/g, '-').replace(/\./, '-'), '.json'].join('')
27 27
 
28 28
 class CoBoxConfig {
29
-  constructor (storage) {
29
+  constructor (storage, opts = {}) {
30 30
     this.root = storage || path.join(os.homedir(), '.cobox')
31 31
     this.storage = path.join(this.root, CONFIG_FILE)
32 32
     this.secrets = path.join(this.root, 'secret_keys')
@@ -34,7 +34,7 @@ class CoBoxConfig {
34 34
     mkdirp.sync(path.join(this.root, 'logs'))
35 35
     mkdirp.sync(this.secrets)
36 36
 
37
-    var config = defaultConfig()
37
+    var config = opts.seeds || defaultConfig()
38 38
     if (!fs.existsSync(this.storage)) {
39 39
       fs.writeFileSync(this.storage, yaml.safeDump(defaultConfig(), { sortKeys: true }))
40 40
       this._groups = config.groups