Skip to content

Commit

Permalink
only use env debug variable
Browse files Browse the repository at this point in the history
  • Loading branch information
joehand committed Jan 3, 2017
1 parent bfc2054 commit c3a4ebe
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 31 deletions.
4 changes: 1 addition & 3 deletions lib/commands/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var nets = require('nets')
var stringKey = require('dat-encoding').toStr
var exit = require('../ui').exitErr
var download = require('../download')
var Debug = require('../debug')
var debug = require('debug')('dat')

module.exports = {
name: 'clone',
Expand All @@ -18,8 +18,6 @@ module.exports = {
}

function clone (opts) {
var debug = Debug(opts)

opts.key = opts._[0]
if (!opts.key) return exit('key required to clone')

Expand Down
3 changes: 1 addition & 2 deletions lib/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var prettyBytes = require('pretty-bytes')
var Dat = require('dat-node')
var ui = require('../ui')
var datJson = require('../dat-json')
var Debug = require('../debug')
var debug = require('debug')('dat')

module.exports = {
name: 'create',
Expand All @@ -18,7 +18,6 @@ module.exports = {
}

function create (opts) {
var debug = Debug(opts)
opts.resume = false // cannot resume for create

var importStatus = null
Expand Down
3 changes: 1 addition & 2 deletions lib/commands/pull.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
var Dat = require('dat-node')
var download = require('../download')
var exitErr = require('../ui').exitErr
var Debug = require('../debug')
var debug = require('debug')('dat')

module.exports = {
name: 'pull',
options: [],
command: function (opts) {
var debug = Debug(opts)
// Force these options for pull command
opts.resume = true
opts.exit = true
Expand Down
3 changes: 1 addition & 2 deletions lib/commands/snapshot.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
var create = require('./create')
var Debug = require('../debug')
var debug = require('debug')('dat')

module.exports = {
name: 'snapshot',
options: [],
command: function snapshot (opts) {
var debug = Debug(opts)
// Force these options for snapshot command
opts.resume = false
opts.live = false
Expand Down
6 changes: 2 additions & 4 deletions lib/commands/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var Dat = require('dat-node')
var download = require('../download')
var share = require('../share')
var exit = require('../ui').exitErr
var Debug = require('../debug')
var debug = require('debug')('dat')

module.exports = {
name: 'sync',
Expand All @@ -14,12 +14,10 @@ module.exports = {
}
],
command: function (opts) {
var debug = Debug(opts)

// Gets overwritten by logger.
// Logging starts after Dat cb for lib/download sync
// So we need this to show something right away
if (!opts.quiet) process.stdout.write('Starting Dat...')
if (!opts.quiet && !opts.debug) process.stdout.write('Starting Dat...')

// Set default options (some of these may be exposed to CLI eventually)
opts.resume = true // sync must always be a resumed archive
Expand Down
12 changes: 0 additions & 12 deletions lib/debug.js

This file was deleted.

4 changes: 1 addition & 3 deletions lib/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ var rimraf = require('rimraf')
var memdb = require('memdb')
var Dat = require('dat-node')
var ui = require('./ui')
var Debug = require('./debug')
var debug = require('debug')('dat')

module.exports = function (type, opts, dat) {
assert.ok(type, 'lib/download download type required')
assert.ok(['sync', 'clone', 'pull'].indexOf(type) > -1, 'lib/download download type must be sync, clone, pull')

var debug = Debug(opts)

// TODO: clean up this logic
var resume = opts.resume || false
if (!opts.key && !resume) return ui.exit()('lib/download Key required to download')
Expand Down
3 changes: 1 addition & 2 deletions lib/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ var logger = require('status-logger')
var prettyBytes = require('pretty-bytes')
var Dat = require('dat-node')
var ui = require('./ui')
var Debug = require('./debug')
var debug = require('debug')('dat')

module.exports = function sync (type, opts, dat) {
assert.ok(type, 'lib/share share type required')
assert.ok(['sync'].indexOf(type) > -1, 'lib/share type must be sync')

var debug = Debug(opts)
debug('Share: ' + type + ' on ' + dat.key.toString('hex'))

var importDone = false
Expand Down
1 change: 0 additions & 1 deletion lib/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module.exports = function (opts) {
console.error('')
console.error(' --dir=<folder> set directory (all commands)')
console.error(' --no-import do not import files (create, sync)')
console.error(' --debug print debugging information')
console.error(' --quiet only print out the dat link')
console.error(' --port=3282 set the port for discovery')
console.error(' --no-utp do not use utp for network connections')
Expand Down

0 comments on commit c3a4ebe

Please sign in to comment.