use configured paths in scripts instead of hardcoded strings

This commit is contained in:
ansuz
2019-04-12 17:16:32 +02:00
parent 36637c4a7f
commit c3d52e87b9
6 changed files with 41 additions and 19 deletions

View File

@@ -3,6 +3,8 @@ const Fs = require('fs');
const nThen = require('nthen');
const Pinned = require('./pinned');
const Nacl = require('tweetnacl');
const Path = require('path');
const Config = require('./load-config');
const hashesFromPinFile = (pinFile, fileName) => {
var pins = {};
@@ -54,7 +56,9 @@ let data = [];
let pinned = [];
nThen((waitFor) => {
let f = '../pins/' + edPublic.slice(0, 2) + '/' + edPublic + '.ndjson';
var pinPath = Config.pinPath || './pins';
let f = Path.join(pinPath, edPublic.slice(0, 2), edPublic + '.ndjson');
Fs.readFile(f, waitFor((err, content) => {
if (err) { throw err; }
pinned = hashesFromPinFile(content.toString('utf8'), f);