Skip to content

Instantly share code, notes, and snippets.

@nginnever
Last active March 25, 2016 23:09
Show Gist options
  • Save nginnever/3c2eedd763ee5b78dd45 to your computer and use it in GitHub Desktop.
Save nginnever/3c2eedd763ee5b78dd45 to your computer and use it in GitHub Desktop.
'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