This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ module.exports = {
16
16
console . log ( 'Initializing daemon...' )
17
17
httpAPI = new HttpAPI ( process . env . IPFS_PATH )
18
18
httpAPI . start ( ( err ) => {
19
+ if ( err . code === 'ENOENT' ) {
20
+ console . log ( 'Error: no ipfs repo found in ' + process . env . IPFS_PATH )
21
+ console . log ( 'please run: jsipfs init' )
22
+ process . exit ( 1 )
23
+ }
19
24
if ( err ) {
20
25
throw err
21
26
}
Original file line number Diff line number Diff line change @@ -25,11 +25,17 @@ exports = module.exports = function HttpApi (repo) {
25
25
}
26
26
27
27
this . ipfs = new IPFS ( repo )
28
+ const repoPath = this . ipfs . repo . path ( )
29
+
30
+ try {
31
+ fs . statSync ( repoPath )
32
+ } catch ( err ) {
33
+ return callback ( err )
34
+ }
28
35
29
36
console . log ( 'Starting at %s' , this . ipfs . repo . path ( ) )
30
37
31
38
this . ipfs . load ( ( ) => {
32
- const repoPath = this . ipfs . repo . path ( )
33
39
const apiPath = path . join ( repoPath , 'api' )
34
40
35
41
try {
Original file line number Diff line number Diff line change
1
+ /* eslint-env mocha */
2
+ 'use strict'
3
+
4
+ const expect = require ( 'chai' ) . expect
5
+ const clean = require ( '../utils/clean' )
6
+ const ipfsCmd = require ( '../utils/ipfs-exec' )
7
+
8
+ describe ( 'daemon' , function ( ) {
9
+ let repoPath
10
+ let ipfs
11
+
12
+ beforeEach ( ( ) => {
13
+ repoPath = '/tmp/ipfs-test-' + Math . random ( ) . toString ( ) . substring ( 2 , 8 )
14
+ ipfs = ipfsCmd ( repoPath )
15
+ } )
16
+
17
+ afterEach ( ( ) => {
18
+ clean ( repoPath )
19
+ } )
20
+
21
+ it ( 'gives error if user hasn\'t run init before' , ( done ) => {
22
+ const expectedError = 'no ipfs repo found in ' + repoPath
23
+ ipfs ( 'daemon' ) . catch ( ( err ) => {
24
+ expect ( err . stdout ) . to . have . string ( expectedError )
25
+ done ( )
26
+ } )
27
+ } )
28
+ } )
You can’t perform that action at this time.
0 commit comments