Skip to content

Commit

Permalink
update standard and lint code (dat-ecosystem#1034)
Browse files Browse the repository at this point in the history
* update standard and lint code

* update appveyor node versions
  • Loading branch information
Joe Hand authored Aug 29, 2018
1 parent 6da3b97 commit 2557f6d
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Test against this version of Node.js
environment:
matrix:
- nodejs_version: "4"
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "10"

# Install scripts. (runs after repo cloning)
install:
Expand Down
4 changes: 2 additions & 2 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var invalidNode = nodeMajorVer < NODE_VERSION_SUPPORTED
if (invalidNode) exitInvalidNode()
else {
var notifier = require('update-notifier')
notifier({pkg: pkg})
notifier({ pkg: pkg })
.notify({
defer: true,
isGlobal: true,
Expand All @@ -23,7 +23,7 @@ else {
borderColor: 'green',
borderStyle: 'classic',
padding: 1,
margin: {top: 1, bottom: 1}
margin: { top: 1, bottom: 1 }
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"random-access-memory": "^3.0.0",
"recursive-readdir-sync": "^1.0.6",
"request": "^2.81.0",
"standard": "^11.0.1",
"standard": "^12.0.0",
"tape": "^4.6.3",
"tape-spawn": "^1.4.2",
"temporary-directory": "^1.0.2"
Expand Down
2 changes: 1 addition & 1 deletion src/commands/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function clone (opts) {
}
}

debug(Object.assign({}, opts, {key: '<private>', _: null})) // don't show key
debug(Object.assign({}, opts, { key: '<private>', _: null })) // don't show key

var neat = neatLog(archiveUI, { logspeed: opts.logspeed, quiet: opts.quiet, debug: opts.debug })
neat.use(trackArchive)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function publish (opts) {

dat.joinNetwork() // join network to upload metadata

var datjson = DatJson(dat.archive, {file: path.join(dat.path, 'dat.json')})
var datjson = DatJson(dat.archive, { file: path.join(dat.path, 'dat.json') })
datjson.read(publish)

function publish (_, data) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/unpublish.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function unpublish (opts) {
// TODO better error msg for non-existing archive
if (!dat.writable) return exitErr('Sorry, you can only publish a dat that you created.')

var datjson = DatJson(dat.archive, {file: path.join(dat.path, 'dat.json')})
var datjson = DatJson(dat.archive, { file: path.join(dat.path, 'dat.json') })
datjson.read(function (err, data) {
if (err) return exitErr(err)
if (!data.name) return exitErr('Try `dat unpublish <name>` with this dat, we are having trouble reading it.')
Expand All @@ -73,7 +73,7 @@ function unpublish (opts) {
}

function makeRequest (name) {
client.dats.delete({name: name}, function (err, resp, body) {
client.dats.delete({ name: name }, function (err, resp, body) {
if (err && err.message) exitErr(err.message)
else if (err) exitErr(err.toString())
if (body.statusCode === 400) return exitErr(new Error(body.message))
Expand Down
2 changes: 1 addition & 1 deletion src/lib/archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function selectiveSync (state, bus) {
bus.emit('render')
if (start === 0 && end === 0) return
debug('downloading', entry, start, end)
archive.content.download({start, end}, function () {
archive.content.download({ start, end }, function () {
debug('success', entry)
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/import-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ function trackImport (state, bus) {
})

progress.on('del', function (src, dst) {
if (src.live) state.importer.liveImports.push({src: src, dst: dst, type: 'del'})
if (src.live) state.importer.liveImports.push({ src: src, dst: dst, type: 'del' })
})

progress.on('put', function (src, dst) {
if (src.live) state.importer.liveImports.push({src: src, dst: dst, type: 'put'})
if (src.live) state.importer.liveImports.push({ src: src, dst: dst, type: 'put' })
if (src.stat.isDirectory()) return
state.importer.fileImport = {
src: src,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/import-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function importUI (state) {
if (total < 5e8 || !file.progress) size = `(${pretty(total)})`
else size = `(${pretty(file.progress)} / ${pretty(total)})`
return output(`
ADD: ${cliTruncate(name, process.stdout.columns - 7 - size.length, {position: 'start'})} ${size}
ADD: ${cliTruncate(name, process.stdout.columns - 7 - size.length, { position: 'start' })} ${size}
`)
}
}
28 changes: 14 additions & 14 deletions test/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ authServer(port, function (err, server, closeServer) {
if (!server) return
test('auth - whoami works when not logged in', function (t) {
var cmd = dat + ' whoami '
var st = spawn(t, cmd, {cwd: baseTestDir})
var st = spawn(t, cmd, { cwd: baseTestDir })
st.stderr.match(function (output) {
t.same(output.trim(), 'Not logged in.', 'printed correct output')
return true
Expand All @@ -35,7 +35,7 @@ authServer(port, function (err, server, closeServer) {

test('auth - register works', function (t) {
var cmd = dat + ' register [email protected] --password=joe --username=joe'
var st = spawn(t, cmd, {cwd: baseTestDir})
var st = spawn(t, cmd, { cwd: baseTestDir })
st.stdout.match(function (output) {
t.same(output.trim(), 'Registered successfully.', 'output success message')
return true
Expand All @@ -46,7 +46,7 @@ authServer(port, function (err, server, closeServer) {

test('auth - login works', function (t) {
var cmd = dat + ' login [email protected] --password=joe'
var st = spawn(t, cmd, {cwd: baseTestDir})
var st = spawn(t, cmd, { cwd: baseTestDir })
st.stdout.match(function (output) {
t.same(output.trim(), 'Logged in successfully.', 'output success message')
return true
Expand All @@ -57,7 +57,7 @@ authServer(port, function (err, server, closeServer) {

test('auth - whoami works', function (t) {
var cmd = dat + ' whoami'
var st = spawn(t, cmd, {cwd: baseTestDir})
var st = spawn(t, cmd, { cwd: baseTestDir })
st.stdout.match(function (output) {
t.same('[email protected]', output.trim(), 'email printed')
return true
Expand All @@ -69,7 +69,7 @@ authServer(port, function (err, server, closeServer) {
test('auth - publish before create fails', function (t) {
var cmd = dat + ' publish'
rimraf.sync(path.join(fixtures, '.dat'))
var st = spawn(t, cmd, {cwd: fixtures})
var st = spawn(t, cmd, { cwd: fixtures })
st.stdout.empty()
st.stderr.match(function (output) {
t.ok(output.indexOf('existing') > -1, 'Create archive before pub')
Expand All @@ -82,7 +82,7 @@ authServer(port, function (err, server, closeServer) {
rimraf.sync(path.join(fixtures, '.dat'))
rimraf.sync(path.join(fixtures, 'dat.json'))
var cmd = dat + ' create --no-import'
var st = spawn(t, cmd, {cwd: fixtures})
var st = spawn(t, cmd, { cwd: fixtures })
st.stdout.match(function (output) {
var link = help.matchLink(output)
if (!link) return false
Expand All @@ -95,7 +95,7 @@ authServer(port, function (err, server, closeServer) {

test('auth - publish our awesome dat', function (t) {
var cmd = dat + ' publish --name awesome'
var st = spawn(t, cmd, {cwd: fixtures})
var st = spawn(t, cmd, { cwd: fixtures })
st.stdout.match(function (output) {
var published = output.indexOf('Successfully published') > -1
if (!published) return false
Expand All @@ -115,7 +115,7 @@ authServer(port, function (err, server, closeServer) {
fs.writeFile(path.join(fixtures, 'dat.json'), JSON.stringify(info), function (err) {
t.ifError(err, 'error after write')
var cmd = dat + ' publish --name awesome'
var st = spawn(t, cmd, {cwd: fixtures})
var st = spawn(t, cmd, { cwd: fixtures })
st.stdout.match(function (output) {
var published = output.indexOf('Successfully published') > -1
if (!published) return false
Expand All @@ -137,7 +137,7 @@ authServer(port, function (err, server, closeServer) {
mkdirp.sync(baseDir)
var downloadDir = path.join(baseDir, shortName.split('/').pop())
var cmd = dat + ' clone ' + shortName
var st = spawn(t, cmd, {cwd: baseDir})
var st = spawn(t, cmd, { cwd: baseDir })
st.stdout.match(function (output) {
var lookingFor = output.indexOf('Looking for') > -1
if (!lookingFor) return false
Expand All @@ -156,7 +156,7 @@ authServer(port, function (err, server, closeServer) {
rimraf(path.join(fixtures, 'dat.json'), function (err) {
t.ifError(err)
var cmd = dat + ' publish --name another-awesome'
var st = spawn(t, cmd, {cwd: fixtures})
var st = spawn(t, cmd, { cwd: fixtures })
st.stdout.match(function (output) {
var published = output.indexOf('Successfully published') > -1
if (!published) return false
Expand All @@ -177,7 +177,7 @@ authServer(port, function (err, server, closeServer) {
mkdirp.sync(baseDir)
var downloadDir = path.join(baseDir, shortName.split('/').pop())
var cmd = dat + ' clone ' + shortName
var st = spawn(t, cmd, {cwd: baseDir})
var st = spawn(t, cmd, { cwd: baseDir })
st.stderr.match(function (output) {
t.same(output.trim(), 'Dat with that name not found.', 'not found')
st.kill()
Expand All @@ -191,7 +191,7 @@ authServer(port, function (err, server, closeServer) {

test('auth - logout works', function (t) {
var cmd = dat + ' logout'
var st = spawn(t, cmd, {cwd: baseTestDir})
var st = spawn(t, cmd, { cwd: baseTestDir })
st.stdout.match(function (output) {
t.same('Logged out.', output.trim(), 'output correct')
return true
Expand All @@ -202,7 +202,7 @@ authServer(port, function (err, server, closeServer) {

test('auth - logout prints correctly when trying to log out twice', function (t) {
var cmd = dat + ' logout'
var st = spawn(t, cmd, {cwd: baseTestDir})
var st = spawn(t, cmd, { cwd: baseTestDir })
st.stderr.match(function (output) {
t.same('Not logged in.', output.trim(), 'output correct')
return true
Expand All @@ -213,7 +213,7 @@ authServer(port, function (err, server, closeServer) {

test('auth - whoami works after logging out', function (t) {
var cmd = dat + ' whoami'
var st = spawn(t, cmd, {cwd: baseTestDir})
var st = spawn(t, cmd, { cwd: baseTestDir })
st.stderr.match(function (output) {
t.same('Not logged in.', output.trim())
return true
Expand Down
24 changes: 12 additions & 12 deletions test/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test('clone - default opts', function (t) {
var key = shareDat.key.toString('hex')
tempDir(function (_, dir, cleanup) {
var cmd = dat + ' clone ' + key
var st = spawn(t, cmd, {cwd: dir})
var st = spawn(t, cmd, { cwd: dir })
var datDir = path.join(dir, key)

st.stdout.match(function (output) {
Expand Down Expand Up @@ -80,7 +80,7 @@ test('clone - specify dir', function (t) {
var key = shareDat.key.toString('hex')
var customDir = 'my_dir'
var cmd = dat + ' clone ' + key + ' ' + customDir
var st = spawn(t, cmd, {cwd: dir})
var st = spawn(t, cmd, { cwd: dir })
st.stdout.match(function (output) {
var downloadFinished = output.indexOf('Exiting') > -1
if (!downloadFinished) return false
Expand All @@ -105,7 +105,7 @@ test('clone - dat:// link', function (t) {
var key = 'dat://' + shareDat.key.toString('hex') + '/'
var cmd = dat + ' clone ' + key + ' '
var downloadDir = path.join(dir, shareDat.key.toString('hex'))
var st = spawn(t, cmd, {cwd: dir})
var st = spawn(t, cmd, { cwd: dir })
st.stdout.match(function (output) {
var downloadFinished = output.indexOf('Exiting') > -1
if (!downloadFinished) return false
Expand All @@ -130,7 +130,7 @@ test('clone - datproject.org/key link', function (t) {
var key = 'datproject.org/' + shareDat.key.toString('hex') + '/'
var cmd = dat + ' clone ' + key + ' '
var downloadDir = path.join(dir, shareDat.key.toString('hex'))
var st = spawn(t, cmd, {cwd: dir})
var st = spawn(t, cmd, { cwd: dir })
st.stdout.match(function (output) {
var downloadFinished = output.indexOf('Exiting') > -1
if (!downloadFinished) return false
Expand Down Expand Up @@ -197,7 +197,7 @@ test('clone - invalid link', function (t) {
var key = 'best-key-ever'
var cmd = dat + ' clone ' + key
tempDir(function (_, dir, cleanup) {
var st = spawn(t, cmd, {cwd: dir})
var st = spawn(t, cmd, { cwd: dir })
var datDir = path.join(dir, key)
st.stderr.match(function (output) {
var error = output.indexOf('Could not resolve link') > -1
Expand Down Expand Up @@ -276,7 +276,7 @@ test('clone - shortcut/stateless clone', function (t) {
test('clone - specify directory containing dat.json', function (t) {
help.shareFixtures(function (_, shareDat) {
tempDir(function (_, dir, cleanup) {
fs.writeFileSync(path.join(dir, 'dat.json'), JSON.stringify({url: shareDat.key.toString('hex')}), 'utf8')
fs.writeFileSync(path.join(dir, 'dat.json'), JSON.stringify({ url: shareDat.key.toString('hex') }), 'utf8')

// dat clone /dir
var cmd = dat + ' clone ' + dir
Expand Down Expand Up @@ -315,11 +315,11 @@ test('clone - specify directory containing dat.json', function (t) {
test('clone - specify directory containing dat.json with cwd', function (t) {
help.shareFixtures(function (_, shareDat) {
tempDir(function (_, dir, cleanup) {
fs.writeFileSync(path.join(dir, 'dat.json'), JSON.stringify({url: shareDat.key.toString('hex')}), 'utf8')
fs.writeFileSync(path.join(dir, 'dat.json'), JSON.stringify({ url: shareDat.key.toString('hex') }), 'utf8')

// cd dir && dat clone /dir/dat.json
var cmd = dat + ' clone ' + dir
var st = spawn(t, cmd, {cwd: dir})
var st = spawn(t, cmd, { cwd: dir })
var datDir = dir

st.stdout.match(function (output) {
Expand Down Expand Up @@ -355,7 +355,7 @@ test('clone - specify dat.json path', function (t) {
help.shareFixtures(function (_, shareDat) {
tempDir(function (_, dir, cleanup) {
var datJsonPath = path.join(dir, 'dat.json')
fs.writeFileSync(datJsonPath, JSON.stringify({url: shareDat.key.toString('hex')}), 'utf8')
fs.writeFileSync(datJsonPath, JSON.stringify({ url: shareDat.key.toString('hex') }), 'utf8')

// dat clone /dir/dat.json
var cmd = dat + ' clone ' + datJsonPath
Expand Down Expand Up @@ -395,11 +395,11 @@ test('clone - specify dat.json path with cwd', function (t) {
help.shareFixtures(function (_, shareDat) {
tempDir(function (_, dir, cleanup) {
var datJsonPath = path.join(dir, 'dat.json')
fs.writeFileSync(datJsonPath, JSON.stringify({url: shareDat.key.toString('hex')}), 'utf8')
fs.writeFileSync(datJsonPath, JSON.stringify({ url: shareDat.key.toString('hex') }), 'utf8')

// cd /dir && dat clone /dir/dat.json
var cmd = dat + ' clone ' + datJsonPath
var st = spawn(t, cmd, {cwd: dir})
var st = spawn(t, cmd, { cwd: dir })
var datDir = dir

st.stdout.match(function (output) {
Expand Down Expand Up @@ -438,7 +438,7 @@ test('clone - specify dat.json + directory', function (t) {
var datJsonPath = path.join(dir, 'dat.json') // make dat.json in different dir

fs.mkdirSync(datDir)
fs.writeFileSync(datJsonPath, JSON.stringify({url: shareDat.key.toString('hex')}), 'utf8')
fs.writeFileSync(datJsonPath, JSON.stringify({ url: shareDat.key.toString('hex') }), 'utf8')

// dat clone /dir/dat.json /dir/clone-dest
var cmd = dat + ' clone ' + datJsonPath + ' ' + datDir
Expand Down
10 changes: 5 additions & 5 deletions test/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ try { fs.unlinkSync(path.join(fixtures, 'dat.json')) } catch (e) { /* ignore err
test('create - default opts no import', function (t) {
tempDir(function (_, dir, cleanup) {
var cmd = dat + ' create --title data --description thing'
var st = spawn(t, cmd, {cwd: dir})
var st = spawn(t, cmd, { cwd: dir })

st.stdout.match(function (output) {
var datCreated = output.indexOf('Created empty Dat') > -1
Expand All @@ -41,7 +41,7 @@ test('create - errors on existing archive', function (t) {
t.error(err, 'no error')
dat.close(function () {
var cmd = dat + ' create --title data --description thing'
var st = spawn(t, cmd, {cwd: dir})
var st = spawn(t, cmd, { cwd: dir })
st.stderr.match(function (output) {
t.ok(output, 'errors')
st.kill()
Expand All @@ -56,7 +56,7 @@ test('create - errors on existing archive', function (t) {
test('create - sync after create ok', function (t) {
tempDir(function (_, dir, cleanup) {
var cmd = dat + ' create --title data --description thing'
var st = spawn(t, cmd, {cwd: dir, end: false})
var st = spawn(t, cmd, { cwd: dir, end: false })
st.stdout.match(function (output) {
var connected = output.indexOf('Created empty Dat') > -1
if (!connected) return false
Expand All @@ -66,7 +66,7 @@ test('create - sync after create ok', function (t) {

function doSync () {
var cmd = dat + ' sync '
var st = spawn(t, cmd, {cwd: dir})
var st = spawn(t, cmd, { cwd: dir })

st.stdout.match(function (output) {
var connected = output.indexOf('Sharing') > -1
Expand All @@ -83,7 +83,7 @@ test('create - sync after create ok', function (t) {
test('create - init alias', function (t) {
tempDir(function (_, dir, cleanup) {
var cmd = dat + ' init --title data --description thing'
var st = spawn(t, cmd, {cwd: dir})
var st = spawn(t, cmd, { cwd: dir })

st.stdout.match(function (output) {
var datCreated = output.indexOf('Created empty Dat') > -1
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function shareFixtures (opts, cb) {
dat.trackStats()
dat.joinNetwork()
if (opts.import === false) return cb(null, dat)
dat.importFiles({watch: false}, function (err) {
dat.importFiles({ watch: false }, function (err) {
if (err) throw err
cb(null, dat)
})
Expand Down
Loading

0 comments on commit 2557f6d

Please sign in to comment.