From ca700cc985666b0450c88cd8670fbacdee3e2137 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 15 Aug 2016 10:44:28 +0100 Subject: [PATCH] fix(repo): init does not break if no opts are passed. Fixes #349 --- src/core/ipfs/init.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/ipfs/init.js b/src/core/ipfs/init.js index a9116dab9a..43792d3a0a 100644 --- a/src/core/ipfs/init.js +++ b/src/core/ipfs/init.js @@ -12,12 +12,16 @@ const Importer = require('ipfs-unixfs-engine').importer module.exports = function init (self) { return (opts, callback) => { - opts = opts || {} + if (typeof opts === 'function') { + callback = opts + opts = {} + } + opts.emptyRepo = opts.emptyRepo || false opts.bits = opts.bits || 2048 // Pre-set config values. - var config = JSON.parse(fs.readFileSync(path.join(__dirname, '../../init-files/default-config.json')).toString()) + const config = JSON.parse(fs.readFileSync(path.join(__dirname, '../../init-files/default-config.json')).toString()) // Verify repo does not yet exist. self._repo.exists((err, exists) => {