Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const os = require('os')
const fs = require('fs').promises
const repl = require('repl')
const minimist = require('minimist')
const RAM = require('random-access-memory')

const { Server, Client } = require('../')
const { migrate: migrateFromDaemon, isMigrated } = require('@hyperspace/migration-tool')
Expand All @@ -21,6 +22,7 @@ const argv = minimist(process.argv.slice(2), {
},
alias: {
host: 'h',
port: 'p',
storage: 's',
bootstrap: 'b'
}
Expand Down Expand Up @@ -67,7 +69,11 @@ async function main () {
// For now, the storage path is determined as follows:
// If ~/.hyperdrive/storage/cores exists, use that (from an old hyperdrive daemon installation)
// Else, use ~/.hyperspace/storage
const storage = argv.storage ? argv.storage : await getStoragePath()
const storage = argv['memory-only']
? getMemoryStorage()
: argv.storage ? argv.storage : await getStoragePath()

console.log(`Using '${storage}' for storage`)

const s = new Server({
host: argv.host,
Expand Down Expand Up @@ -144,6 +150,11 @@ async function getStoragePath () {
}
}

function getMemoryStorage () {
RAM.toString = () => 'RAM'
return RAM
}

function onerror (err) {
console.error(err.stack)
process.exit(1)
Expand Down