Skip to content

Commit

Permalink
do not import on create (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
joehand authored Jan 19, 2017
1 parent 585ffa0 commit 020ffd3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {
{
name: 'import',
boolean: true,
default: true,
default: false,
help: 'Import files in the given directory'
},
{
Expand Down Expand Up @@ -59,7 +59,7 @@ function create (opts) {
if (err) return exit(err)

// General Archive Info
output[0] = `Dat ${opts.live !== false ? 'Archive' : 'Snapshot Archive'} initialized: ${dat.path}`
output[0] = `Dat ${opts.live !== false ? 'Archive' : 'Snapshot Archive'} created: ${dat.path}`
if (dat.key) output[1] = ui.link(dat.key) + '\n'
else output[1] = 'Creating link...' + '\n'
if (opts.quiet && dat.key) process.stdout.write(ui.link(dat.key))
Expand Down
28 changes: 24 additions & 4 deletions tests/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,32 @@ try { fs.unlinkSync(path.join(fixtures, '.DS_Store')) } catch (e) { /* ignore er
// start without dat.json
try { fs.unlinkSync(path.join(fixtures, 'dat.json')) } catch (e) { /* ignore error */ }

test('create - default opts', function (t) {
test('create - default opts no import', function (t) {
rimraf.sync(path.join(fixtures, '.dat'))
// cmd: dat create

var cmd = dat + ' create'
var st = spawn(t, cmd, {cwd: fixtures})

st.stdout.match(function (output) {
var datCreated = output.indexOf('created') > -1
if (!datCreated) return false

t.ok(help.isDir(path.join(fixtures, '.dat')), 'creates dat directory')

st.kill()
return true
})
st.succeeds('exits after create finishes')
st.stderr.empty()
st.end()
})

test('create - default opts with import', function (t) {
rimraf.sync(path.join(fixtures, '.dat'))
// cmd: dat create
var cmd = dat + ' create --import'
var st = spawn(t, cmd, {cwd: fixtures})

st.stdout.match(function (output) {
var importFinished = output.indexOf('import finished') > -1
if (!importFinished) return false
Expand Down Expand Up @@ -104,7 +124,7 @@ test('create - quiet only prints link', function (t) {

test('create - init alias okay', function (t) {
rimraf.sync(path.join(fixtures, '.dat'))
var cmd = dat + ' init'
var cmd = dat + ' init --import'
var st = spawn(t, cmd, {cwd: fixtures})

st.stderr.empty()
Expand All @@ -120,7 +140,7 @@ test('create - init alias okay', function (t) {

test('create - with path', function (t) {
rimraf.sync(path.join(fixtures, '.dat'))
var cmd = dat + ' create ' + fixtures
var cmd = dat + ' create --import ' + fixtures
var st = spawn(t, cmd)

st.stderr.empty()
Expand Down
1 change: 0 additions & 1 deletion tests/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ test('snapshot - default opts', function (t) {
t.ok(output.indexOf('tests/fixtures') > -1, 'prints dir')
t.ok(output.match(fileRe), 'total size: files okay')
t.ok(output.match(bytesRe), 'total size: bytes okay')

st.kill()
return true
})
Expand Down
6 changes: 3 additions & 3 deletions tests/sync-owner.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test('sync-owner - errors without create first', function (t) {
test('sync-owner - create a dat for syncing', function (t) {
rimraf.sync(path.join(fixtures, '.dat'))
// cmd: dat create
var cmd = dat + ' create'
var cmd = dat + ' create --import'
var st = spawn(t, cmd, {cwd: fixtures})
st.stdout.match(function (output) {
var importFinished = output.indexOf('import finished') > -1
Expand Down Expand Up @@ -92,10 +92,10 @@ test('sync-owner - default opts', function (t) {
test('sync-owner - create without import for syncing', function (t) {
rimraf.sync(path.join(fixtures, '.dat'))
// cmd: dat create
var cmd = dat + ' create --no-import'
var cmd = dat + ' create'
var st = spawn(t, cmd, {cwd: fixtures})
st.stdout.match(function (output) {
if (output.indexOf('Archive initialized') > -1) return true
if (output.indexOf('created') > -1) return true
return false
})
st.succeeds()
Expand Down

0 comments on commit 020ffd3

Please sign in to comment.