diff --git a/lib/commands/create.js b/lib/commands/create.js index d9e79cb..5bc1684 100644 --- a/lib/commands/create.js +++ b/lib/commands/create.js @@ -17,7 +17,7 @@ module.exports = { { name: 'import', boolean: true, - default: true, + default: false, help: 'Import files in the given directory' }, { @@ -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)) diff --git a/tests/create.js b/tests/create.js index 3324c24..7713afd 100644 --- a/tests/create.js +++ b/tests/create.js @@ -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 @@ -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() @@ -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() diff --git a/tests/snapshot.js b/tests/snapshot.js index 9fc10b4..f4bd93e 100644 --- a/tests/snapshot.js +++ b/tests/snapshot.js @@ -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 }) diff --git a/tests/sync-owner.js b/tests/sync-owner.js index 1208470..6d730ca 100644 --- a/tests/sync-owner.js +++ b/tests/sync-owner.js @@ -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 @@ -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()