Last active
March 25, 2016 23:09
-
-
Save nginnever/3c2eedd763ee5b78dd45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const Command = require('ronin').Command | |
const IPFS = require('../../../core') | |
const debug = require('debug') | |
const log = debug('cli:version') | |
log.error = debug('cli:version:error') | |
const bs58 = require('bs58') | |
module.exports = Command.extend({ | |
desc: 'Add a file to IPFS using the UnixFS data format', | |
options: { | |
recursive: { | |
alias: 'r', | |
type: 'boolean', | |
default: false | |
} | |
}, | |
run: (recursive, path) => { | |
var node = new IPFS() | |
if (path.charAt(0) !== '/') { | |
path = process.cwd() + '/' + path | |
} | |
node.files.add(path, { | |
recursive: recursive | |
}, (err, stats) => { | |
if (err) { | |
return console.log(err) | |
} | |
if (stats) { | |
console.log('added', bs58.encode(stats.Hash).toString(), stats.Name) | |
} | |
}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment