@@ -7,9 +7,8 @@ const { spawn } = require('child_process')
7
7
const minimist = require ( 'minimist' )
8
8
const ram = require ( 'random-access-memory' )
9
9
10
- const { Server, Client } = require ( './' )
10
+ const { Server, Client } = require ( '.. /' )
11
11
const { migrate : migrateFromDaemon , isMigrated } = require ( '@hyperspace/migration-tool' )
12
- const getNetworkOptions = require ( '@hyperspace/rpc/socket' )
13
12
14
13
// TODO: Default paths are duplicated here because we need to do the async migration check.
15
14
const HYPERSPACE_STORAGE_DIR = p . join ( os . homedir ( ) , '.hyperspace' , 'storage' )
@@ -26,21 +25,15 @@ const argv = minimist(process.argv.slice(2), {
26
25
host : 'h' ,
27
26
storage : 's' ,
28
27
bootstrap : 'b'
29
- } ,
30
- '--' : true
28
+ }
31
29
} )
32
- console . log ( 'argv:' , argv )
33
30
34
- const version = `hyperspace/${ require ( './package.json' ) . version } ${ process . platform } -${ process . arch } node-${ process . version } `
31
+ const version = `hyperspace/${ require ( '.. /package.json' ) . version } ${ process . platform } -${ process . arch } node-${ process . version } `
35
32
36
33
const help = `Hypercore, batteries included.
37
34
${ version }
38
35
39
- Usage: hyperspace [command] [options]
40
- Commands:
41
- simulator <script.js> Run script.js using an in-memory Hyperspace instance
42
-
43
- Flags:
36
+ Usage: hyperspace [options]
44
37
--host, -h Set unix socket name
45
38
--port -p Set the port (will use TCP)
46
39
--storage, -s Overwrite storage folder
@@ -59,10 +52,6 @@ if (argv.help) {
59
52
main ( ) . catch ( onerror )
60
53
61
54
async function main ( ) {
62
- if ( argv . _ [ 0 ] === 'simulator' ) {
63
- return simulator ( )
64
- }
65
-
66
55
console . log ( 'Running ' + version )
67
56
68
57
// Note: This will be removed in future releases of Hyperspace.
@@ -149,33 +138,6 @@ function createServer (storage, opts) {
149
138
} )
150
139
}
151
140
152
- async function simulator ( ) {
153
- if ( argv . _ . length === 1 ) throw new Error ( 'Must provide a script for the simulator to run.' )
154
- const scriptPath = p . resolve ( argv . _ [ 1 ] )
155
- const simulatorId = `hyperspace-simulator-${ process . pid } `
156
- process . env . HYPERSPACE_SOCKET = simulatorId
157
-
158
- const server = createServer ( ram , {
159
- ...argv ,
160
- host : simulatorId
161
- } )
162
- await server . open ( )
163
-
164
- process . once ( 'SIGINT' , close )
165
- process . once ( 'SIGTERM' , close )
166
-
167
- const childArgs = argv [ '--' ] || [ ]
168
- const child = spawn ( process . execPath , [ scriptPath , ...childArgs ] , {
169
- stdio : 'inherit'
170
- } )
171
- child . on ( 'close' , close )
172
-
173
- async function close ( ) {
174
- console . log ( 'Shutting down simulator...' )
175
- server . close ( ) . catch ( onerror )
176
- }
177
- }
178
-
179
141
async function getStoragePath ( ) {
180
142
try {
181
143
// If this dir exists, use it.
0 commit comments