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

Commit 674958d

Browse files
committed
feat(cli): --migrate support
1 parent ad79804 commit 674958d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/cli/parser.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ const parser = yargs
1919
type: 'string',
2020
default: ''
2121
})
22+
.option('migrate', {
23+
desc: 'Allows automatic migrations',
24+
type: 'boolean',
25+
default: false
26+
})
2227
.epilog(utils.ipfsPathHelp)
2328
.demandCommand(1)
2429
.fail((msg, err, yargs) => {

src/cli/utils.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ exports.getIPFS = (argv, callback) => {
4747
const IPFS = require('../core')
4848
const node = new IPFS({
4949
silent: argv.silent,
50+
repoAutoMigrate: argv.migrate,
5051
repo: exports.getRepoPath(),
5152
init: false,
5253
start: false,
@@ -60,7 +61,11 @@ exports.getIPFS = (argv, callback) => {
6061
})
6162

6263
node.on('error', (err) => {
63-
throw err
64+
if (err.code === 'ERR_INVALID_REPO_VERSION') {
65+
err.message = 'Incompatible repo version. Migration needed. Pass --migrate for automatic migration'
66+
}
67+
68+
callback(null, node, cleanup)
6469
})
6570

6671
node.once('ready', () => {

0 commit comments

Comments
 (0)