Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 64154d6

Browse files
committed
tests and cli stuff
1 parent 6c81f9a commit 64154d6

File tree

4 files changed

+93
-3
lines changed

4 files changed

+93
-3
lines changed

src/cli/commands/config/edit.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict'
2+
3+
const Command = require('ronin').Command
4+
const IPFS = require('../../../ipfs-core')
5+
const debug = require('debug')
6+
const log = debug('cli:version')
7+
log.error = debug('cli:version:error')
8+
9+
module.exports = Command.extend({
10+
desc: 'Shows IPFS version information',
11+
12+
options: {
13+
number: {
14+
alias: 'n',
15+
type: 'boolean',
16+
default: false
17+
},
18+
commit: {
19+
type: 'boolean',
20+
default: false
21+
},
22+
repo: {
23+
type: 'boolean',
24+
default: false
25+
}
26+
},
27+
28+
run: (name) => {
29+
var node = new IPFS()
30+
node.version((err, version) => {
31+
if (err) { return log.error(err) }
32+
33+
console.log(version)
34+
})
35+
}
36+
})

src/cli/commands/config/replace.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict'
2+
3+
const Command = require('ronin').Command
4+
const IPFS = require('../../../ipfs-core')
5+
const debug = require('debug')
6+
const path = require('path')
7+
const log = debug('cli:version')
8+
log.error = debug('cli:version:error')
9+
10+
module.exports = Command.extend({
11+
desc: 'Replaces the config with <file>',
12+
13+
options: {},
14+
15+
run: (configPath) => {
16+
var node = new IPFS()
17+
var config = require(path.resolve(process.cwd(), configPath))
18+
19+
node.config.replace(config, (err, version) => {
20+
if (err) { return log.error(err) }
21+
22+
console.log(version)
23+
})
24+
}
25+
})

src/cli/commands/config/show.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict'
2+
3+
const Command = require('ronin').Command
4+
const IPFS = require('../../../ipfs-core')
5+
const debug = require('debug')
6+
const log = debug('cli:version')
7+
log.error = debug('cli:version:error')
8+
9+
module.exports = Command.extend({
10+
desc: 'Outputs the content of the config file',
11+
12+
options: {},
13+
14+
run: () => {
15+
var node = new IPFS()
16+
node.config.show((err, config) => {
17+
if (err) { return log.error(err) }
18+
19+
console.log(JSON.stringify(config, null, 4))
20+
})
21+
}
22+
})

tests/test-core/test-config.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,18 @@ describe('config', () => {
7575
})
7676
})
7777

78-
it.skip('replace', done => {
78+
it('replace', done => {
7979
let ipfs = new IPFS()
80-
ipfs.config((err, config) => {
80+
ipfs.config.replace({}, err => {
8181
expect(err).to.not.exist
82-
done()
82+
ipfs.config.show((err, config) => {
83+
expect(err).to.not.exist
84+
expect(config).to.deep.equal({})
85+
ipfs.config.replace(defaultConfig, err => {
86+
expect(err).to.not.exist
87+
done()
88+
})
89+
})
8390
})
8491
})
8592

0 commit comments

Comments
 (0)