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

Commit f7768b5

Browse files
committedJan 7, 2016
es6ify
1 parent f86cb1b commit f7768b5

21 files changed

+125
-94
lines changed
 

‎src/cli/bin.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#! /usr/bin/env node
22

3-
var ronin = require('ronin')
3+
'use strict'
44

5-
var cli = ronin(__dirname)
5+
const ronin = require('ronin')
6+
7+
const cli = ronin(__dirname)
68

79
cli.run()
810

‎src/cli/commands/add.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
var Command = require('ronin').Command
1+
'use strict'
2+
3+
const Command = require('ronin').Command
24

35
module.exports = Command.extend({
46
desc: '',
57

6-
run: function (name) {}
8+
run: name => {}
79
})

‎src/cli/commands/commands.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
var Command = require('ronin').Command
1+
'use strict'
2+
3+
const Command = require('ronin').Command
24

35
module.exports = Command.extend({
46
desc: '',
57

6-
run: function (name) {}
8+
run: name => {}
79
})

‎src/cli/commands/daemon.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
var Command = require('ronin').Command
2-
var httpAPI = require('../../http-api')
1+
'use strict'
2+
3+
const Command = require('ronin').Command
4+
const httpAPI = require('../../http-api')
5+
const debug = require('debug')
6+
let log = debug('cli:daemon')
7+
log.error = debug('cli:damon:error')
38

49
module.exports = Command.extend({
510
desc: 'Start a long-running daemon process',
611

7-
run: function (name) {
8-
httpAPI.start()
9-
// start API, using core
10-
//
12+
run: name => {
13+
httpAPI.start((err) => {
14+
if (err) { return log.error(err) }
15+
log('daemon started')
16+
})
1117
}
1218
})

‎src/cli/commands/dns.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
var Command = require('ronin').Command
1+
'use strict'
2+
3+
const Command = require('ronin').Command
24

35
module.exports = Command.extend({
46
desc: '',
57

6-
run: function (name) {}
8+
run: name => {}
79
})

‎src/cli/commands/get.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
var Command = require('ronin').Command
1+
const Command = require('ronin').Command
22

33
module.exports = Command.extend({
44
desc: '',
55

6-
run: function (name) {}
6+
run: name => {}
77
})

‎src/cli/commands/id.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
var Command = require('ronin').Command
2-
var IPFS = require('../../ipfs-core')
1+
const Command = require('ronin').Command
2+
const IPFS = require('../../ipfs-core')
3+
const debug = require('debug')
4+
let log = debug('cli:id')
5+
log.error = debug('cli:id:error')
36

47
module.exports = Command.extend({
58
desc: 'Shows IPFS Node ID info',
@@ -11,12 +14,10 @@ module.exports = Command.extend({
1114
}
1215
},
1316

14-
run: function (name) {
15-
var node = new IPFS()
16-
node.id(function (err, id) {
17-
if (err) {
18-
return console.error(err)
19-
}
17+
run: name => {
18+
let node = new IPFS()
19+
node.id((err, id) => {
20+
if (err) { return log.error(err) }
2021
console.log(id)
2122
})
2223
}

‎src/cli/commands/init.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
var Command = require('ronin').Command
2-
// var help = require('../src/help-menu.js')
1+
'use strict'
2+
3+
const Command = require('ronin').Command
34

45
module.exports = Command.extend({
56
desc: 'Initialize ipfs local configuration',
67

7-
// help: help,
8-
98
options: {
109
bits: {
1110
type: 'number',
@@ -25,7 +24,5 @@ module.exports = Command.extend({
2524
}
2625
},
2726

28-
run: function (name) {
29-
console.log('NA - https://github.com/ipfs/js-ipfs/tree/jsipfs#getting-jsipfs-ready')
30-
}
27+
run: name => {}
3128
})

‎src/cli/commands/ls.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
var Command = require('ronin').Command
1+
'use strict'
2+
3+
const Command = require('ronin').Command
24

35
module.exports = Command.extend({
46
desc: '',
57

6-
run: function (name) {}
8+
run: name => {}
79
})

‎src/cli/commands/mount.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
var Command = require('ronin').Command
1+
'use strict'
2+
3+
const Command = require('ronin').Command
24

35
module.exports = Command.extend({
46
desc: '',
57

6-
run: function (name) {}
8+
run: name => {}
79
})

‎src/cli/commands/ping.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
var Command = require('ronin').Command
1+
'use strict'
2+
3+
const Command = require('ronin').Command
24

35
module.exports = Command.extend({
46
desc: '',
57

6-
run: function (name) {}
8+
run: name => {}
79
})

‎src/cli/commands/refs.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
var Command = require('ronin').Command
1+
'use strict'
2+
3+
const Command = require('ronin').Command
24

35
module.exports = Command.extend({
46
desc: '',
57

6-
run: function (name) {}
8+
run: name => {}
79
})

‎src/cli/commands/resolve.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
var Command = require('ronin').Command
1+
'use strict'
2+
3+
const Command = require('ronin').Command
24

35
module.exports = Command.extend({
46
desc: '',
57

6-
run: function (name) {}
8+
run: name => {}
79
})

‎src/cli/commands/update.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
var Command = require('ronin').Command
1+
'use strict'
2+
3+
const Command = require('ronin').Command
24

35
module.exports = Command.extend({
46
desc: '',
57

6-
run: function (name) {}
8+
run: name => {}
79
})

‎src/cli/commands/version.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
var Command = require('ronin').Command
2-
var IPFS = require('../../ipfs-core')
3-
var debug = require('debug')
4-
var log = debug('cli:version')
1+
'use strict'
2+
3+
const Command = require('ronin').Command
4+
const IPFS = require('../../ipfs-core')
5+
const debug = require('debug')
6+
let log = debug('cli:version')
57
log.error = debug('cli:version:error')
68

79
module.exports = Command.extend({
@@ -23,9 +25,9 @@ module.exports = Command.extend({
2325
}
2426
},
2527

26-
run: function (name) {
28+
run: (name) => {
2729
var node = new IPFS()
28-
node.version(function (err, version) {
30+
node.version((err, version) => {
2931
if (err) { return log.error(err) }
3032

3133
console.log(version)

‎src/http-api/index.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
var Hapi = require('hapi')
2-
var IPFS = require('../ipfs-core')
3-
var debug = require('debug')
4-
var log = debug('api')
1+
'use strict'
2+
3+
const Hapi = require('hapi')
4+
const IPFS = require('../ipfs-core')
5+
const debug = require('debug')
6+
let log = debug('api')
7+
log.error = debug('api:error')
58

69
exports = module.exports
710

8-
exports.start = function (callback) {
11+
exports.start = callback => {
912
// start IPFS and exports.ipfs = new IPFS()
1013

1114
exports.ipfs = new IPFS()
@@ -25,13 +28,13 @@ exports.start = function (callback) {
2528
// load routes
2629
require('./routes/version.js')
2730

28-
server.start(function (err) {
31+
server.start(err => {
2932
if (err) { return callback(err) }
3033
log('server started: ' + server.info.uri)
3134
callback()
3235
})
3336
}
3437

35-
exports.stop = function () {
38+
exports.stop = () => {
3639

3740
}

‎src/http-api/resources/version.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
var ipfs = require('./../index.js').ipfs
2-
var boom = require('boom')
1+
'use strict'
2+
3+
const ipfs = require('./../index.js').ipfs
4+
const boom = require('boom')
35

46
exports = module.exports
57

6-
exports.get = function handler (request, reply) {
7-
ipfs.version(function (err, version) {
8-
if (err) {
9-
return reply(boom.badRequest(err))
10-
}
8+
exports.get = (request, reply) => {
9+
ipfs.version((err, version) => {
10+
if (err) { return reply(boom.badRequest(err)) }
1111
return reply(version)
1212
})
1313
}

‎src/http-api/routes/version.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
var server = require('./../index.js').server
2-
var resources = require('./../resources')
1+
'use strict'
2+
3+
const server = require('./../index.js').server
4+
const resources = require('./../resources')
35

46
server.route({
57
method: 'GET',

‎src/ipfs-core/config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var os = require('os')
1+
'use strict'
2+
3+
const os = require('os')
24

35
exports = module.exports
46

‎src/ipfs-core/index.js

+18-22
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,48 @@
1-
var config = require('./config')
2-
var IPFSRepo = require('ipfs-repo')
1+
'use strict'
2+
3+
const config = require('./config')
4+
const IPFSRepo = require('ipfs-repo')
35

46
exports = module.exports = IPFS
57
exports.config = config
68

79
function IPFS () {
8-
var self = this
9-
10-
if (!(self instanceof IPFS)) {
10+
if (!(this instanceof IPFS)) {
1111
throw new Error('Must be instantiated with new')
1212
}
1313

1414
var repo = new IPFSRepo(config.repoPath)
1515

16-
self.daemon = function (callback) {
16+
this.daemon = (callback) => {
1717
// 1. read repo to get peer data
1818
}
1919

20-
self.version = function (opts, callback) {
20+
this.version = (opts, callback) => {
2121
if (typeof opts === 'function') {
2222
callback = opts
2323
opts = {}
2424
}
2525

26-
repo.exists(function (err, exists) {
26+
repo.exists((err, exists) => {
2727
if (err) { return callback(err) }
2828

29-
repo.config.get(function (err, config) {
29+
repo.config.get((err, config) => {
3030
if (err) { return callback(err) }
3131

3232
callback(null, config.Version.Current)
3333
})
3434
})
3535
}
3636

37-
self.id = function (opts, callback) {
37+
this.id = (opts, callback) => {
3838
if (typeof opts === 'function') {
3939
callback = opts
4040
opts = {}
4141
}
42-
repo.exists(function (err, exists) {
43-
if (err) {
44-
return callback(err)
45-
}
42+
repo.exists((err, exists) => {
43+
if (err) { return callback(err) }
4644

47-
repo.config.read(function (err, config) {
45+
repo.config.read((err, config) => {
4846
if (err) {
4947
return callback(err)
5048
}
@@ -60,20 +58,18 @@ function IPFS () {
6058
})
6159
}
6260

63-
self.repo = {
64-
init: function (bits, force, empty, callback) {
61+
this.repo = {
62+
init: (bits, force, empty, callback) => {
6563
// 1. check if repo already exists
6664
},
6765

68-
version: function (opts, callback) {
66+
version: (opts, callback) => {
6967
if (typeof opts === 'function') {
7068
callback = opts
7169
opts = {}
7270
}
73-
repo.exists(function (err, res) {
74-
if (err) {
75-
return callback(err)
76-
}
71+
repo.exists((err, res) => {
72+
if (err) { return callback(err) }
7773
repo.version.read(callback)
7874
})
7975
},

‎tests/test-core/test-version.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
/* globals describe, it */
22

3-
var expect = require('chai').expect
3+
'use strict'
4+
5+
const expect = require('chai').expect
46

57
process.env.IPFS_PATH = process.cwd() + '/tests/repo-example'
6-
var IPFS = require('../../src/ipfs-core')
8+
const IPFS = require('../../src/ipfs-core')
79

8-
describe('core: version', function () {
9-
it('get version', function (done) {
10-
var ipfs = new IPFS()
11-
ipfs.version(function (err, version) {
10+
describe('core: version', () => {
11+
it('get version', done => {
12+
let ipfs = new IPFS()
13+
ipfs.version((err, version) => {
1214
expect(err).to.not.exist
1315
expect(version).to.equal('0.4.0-dev')
1416
done()

0 commit comments

Comments
 (0)
This repository has been archived.