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

Commit

Permalink
Merge pull request #97 from noffle/no-force
Browse files Browse the repository at this point in the history
removes --force
  • Loading branch information
daviddias committed Apr 2, 2016
2 parents 94f26f0 + 014d618 commit 27c38c4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function IPFS (repo) {
}

this.repo = {
init: (bits, force, empty, callback) => {
init: (bits, empty, callback) => {
// 1. check if repo already exists
},

Expand Down
7 changes: 3 additions & 4 deletions src/core/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ const path = require('path')

module.exports = (repo, opts, callback) => {
opts = opts || {}
opts.force = opts.force || false
opts.emptyRepo = opts.emptyRepo || false
opts.bits = opts.bits || 2048

// Pre-set config values.
var config = require('../init-files/default-config.json')

// Verify repo does not yet exist (or that 'force' is provided).
// Verify repo does not yet exist.
repo.exists((err, res) => {
if (err) { return callback(err) }
if (res === true && !opts.force) {
return callback(new Error('repo already exists and \'force\' is not set'))
if (res === true) {
return callback(new Error('repo already exists'))
}

generateAndSetKeypair()
Expand Down
19 changes: 0 additions & 19 deletions test/core-tests/test-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,4 @@ describe('init', function () {
})
})
})

it('force init (overwrite)', (done) => {
var repo = createTempRepo()
const ipfs1 = new IPFS(repo)
const ipfs2 = new IPFS(repo)
ipfs1.init({ bits: 128, emptyRepo: true }, (err) => {
expect(err).to.not.exist

ipfs2.init({ bits: 128, force: false }, (err) => {
expect(err).to.exist

ipfs2.init({ force: true }, (err) => {
expect(err).to.not.exist

repo.teardown(done)
})
})
})
})
})

0 comments on commit 27c38c4

Please sign in to comment.