braidfs 0.0.18 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +14 -15
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -9,22 +9,20 @@ process.on("unhandledRejection", (x) => console.log(`unhandledRejection: ${x.sta
9
9
  process.on("uncaughtException", (x) => console.log(`uncaughtException: ${x.stack}`))
10
10
 
11
11
  let braidfs_config_dir = require('path').join(require('os').homedir(), '.braidfs')
12
- let braidfs_config_path = require('path').join(braidfs_config_dir, 'config.json')
13
- braid_text.db_folder = require('path').join(braidfs_config_dir, 'braid-text-db')
14
-
15
- let config = {
16
- port: 10000,
17
- sync_urls: [],
18
- sync_index_urls: [],
19
- proxy_base: require('path').join(require('os').homedir(), 'http'),
20
- proxy_base_last_versions: require('path').join(braidfs_config_dir, 'proxy_base_last_versions')
12
+
13
+ let braidfs_config_file = require('path').join(braidfs_config_dir, 'config.json')
14
+ if (!require('fs').existsSync(braidfs_config_file)) {
15
+ require('fs').writeFileSync(braidfs_config_file, JSON.stringify({
16
+ port: 10000,
17
+ sync_urls: [],
18
+ sync_index_urls: [],
19
+ proxy_base: require('path').join(require('os').homedir(), 'http'),
20
+ proxy_base_last_versions: require('path').join(braidfs_config_dir, 'proxy_base_last_versions'),
21
+ braid_text_db: require('path').join(braidfs_config_dir, 'braid-text-db'),
22
+ }, null, 4))
21
23
  }
22
24
 
23
- // process config file
24
- try {
25
- console.log(`loading config file at: ${braidfs_config_path}`)
26
- Object.assign(config, JSON.parse(require('fs').readFileSync(braidfs_config_path, 'utf8')))
27
- } catch (e) { console.error(`Error loading config file:`, e.message) }
25
+ let config = JSON.parse(require('fs').readFileSync(braidfs_config_file, 'utf8'))
28
26
 
29
27
  // process command line args (override config)
30
28
  let argv = process.argv.slice(2)
@@ -42,7 +40,8 @@ while (argv.length) {
42
40
  }
43
41
  }
44
42
 
45
- // create directories
43
+ braid_text.db_folder = config.braid_text_db
44
+
46
45
  require('fs').mkdirSync(config.proxy_base, { recursive: true })
47
46
  require('fs').mkdirSync(config.proxy_base_last_versions, { recursive: true })
48
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braidfs",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "braid technology synchronizing files and webpages",
5
5
  "author": "Braid Working Group",
6
6
  "repository": "braid-org/braidfs",