Permalink
Browse files

use cwd for link default

  • Loading branch information...
maxogden committed Jan 5, 2016
1 parent e8efcff commit c29fe52378fcdd025c6b664f6fc371b0592e2a6b
Showing with 15 additions and 0 deletions.
  1. +1 −0 cli.js
  2. +14 −0 tests/link.js
View
1 cli.js
@@ -17,6 +17,7 @@ function run () {
var db = dat({home: args.home})
if (firstArg === 'link') {
var dirs = args._.slice(1)
if (dirs.length === 0) dirs = process.cwd()
db.add(dirs, function (err, link) {
if (err) throw err
db.joinTcpSwarm(link, function (_err, link, port, close) {
View
@@ -8,11 +8,25 @@ var path = require('path')
var dat = path.resolve(path.join(__dirname, '..', 'cli.js'))
var dat1 = path.join(__dirname, 'fixtures')
var tmp = os.tmpdir()
var dat1link
test('prints link', function (t) {
var st = spawn(t, dat + ' link ' + dat1 + ' --home=' + tmp)
st.stdout.match(function (output) {
t.equal(output.length, 71, 'version is length 71: dat:// + 64 char hash + newline')
dat1link = output.toString()
st.kill()
return true
})
st.stderr.empty()
st.end()
})
test('link with no args defaults to cwd', function (t) {
var st = spawn(t, dat + ' link --home=' + tmp, {cwd: dat1})
st.stdout.match(function (output) {
t.equal(output.length, 71, 'version is length 71: dat:// + 64 char hash + newline')
t.equal(output.toString(), dat1link, 'links match')
st.kill()
return true
})

0 comments on commit c29fe52

Please sign in to comment.