This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 3 files changed +21
-21
lines changed
3 files changed +21
-21
lines changed Original file line number Diff line number Diff line change 1
1
const Command = require ( 'ronin' ) . Command
2
- const IPFS = require ( '../../ipfs-core' )
3
2
const debug = require ( 'debug' )
4
3
const utils = require ( '../utils' )
5
4
const log = debug ( 'cli' )
@@ -16,22 +15,13 @@ module.exports = Command.extend({
16
15
} ,
17
16
18
17
run : ( name ) => {
19
- if ( utils . isDaemonOn ( ) ) {
20
- const ctl = utils . getAPICtl ( )
21
- ctl . id ( ( err , result ) => {
22
- if ( err ) {
23
- return log . error ( err )
24
- }
25
- console . log ( result )
26
- } )
27
- } else {
28
- const node = new IPFS ( )
29
- node . id ( ( err , id ) => {
30
- if ( err ) {
31
- return log . error ( err )
32
- }
33
- console . log ( id )
34
- } )
35
- }
18
+ var ipfs = utils . getIPFS ( )
19
+
20
+ ipfs . id ( ( err , id ) => {
21
+ if ( err ) {
22
+ return log . error ( err )
23
+ }
24
+ console . log ( id )
25
+ } )
36
26
}
37
27
} )
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ const fs = require('fs')
2
2
const os = require ( 'os' )
3
3
const APIctl = require ( 'ipfs-api' )
4
4
const multiaddr = require ( 'multiaddr' )
5
+ const IPFS = require ( '../ipfs-core' )
5
6
const debug = require ( 'debug' )
6
7
const log = debug ( 'cli' )
7
8
log . error = debug ( 'cli:error' )
@@ -22,11 +23,20 @@ function isDaemonOn () {
22
23
}
23
24
}
24
25
25
- exports . getAPICtl = ( ) => {
26
- if ( ! isDaemonOn ) {
26
+ exports . getAPICtl = getAPICtl
27
+ function getAPICtl ( ) {
28
+ if ( ! isDaemonOn ( ) ) {
27
29
throw new Error ( 'daemon is not on' )
28
30
}
29
31
30
32
const apiAddr = multiaddr ( fs . readFileSync ( repoPath + '/api' ) . toString ( ) )
31
33
return APIctl ( apiAddr . toString ( ) )
32
34
}
35
+
36
+ exports . getIPFS = ( ) => {
37
+ if ( ! isDaemonOn ( ) ) {
38
+ return new IPFS ( )
39
+ }
40
+
41
+ return getAPICtl ( )
42
+ }
Original file line number Diff line number Diff line change 3
3
const expect = require ( 'chai' ) . expect
4
4
const nexpect = require ( 'nexpect' )
5
5
6
- describe ( 'id ' , ( ) => {
6
+ describe ( 'bootstrap ' , ( ) => {
7
7
describe ( 'api offline' , ( ) => {
8
8
const defaultList = [
9
9
'/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ' ,
You can’t perform that action at this time.
0 commit comments