Skip to content

Commit 7799149

Browse files
committed
fix(standard): standard --fix
1 parent 03d7dfe commit 7799149

File tree

17 files changed

+64
-64
lines changed

17 files changed

+64
-64
lines changed

lib/content/path.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ssri = require('ssri')
1212
//
1313
module.exports = contentPath
1414
function contentPath (cache, integrity) {
15-
const sri = ssri.parse(integrity, {single: true})
15+
const sri = ssri.parse(integrity, { single: true })
1616
// contentPath is the *strongest* algo given
1717
return path.join.apply(path, [
1818
contentDir(cache),

lib/content/read.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ function readStream (cache, integrity, opts) {
5454
opts = ReadOpts(opts)
5555
const stream = new PassThrough()
5656
withContentSri(cache, integrity, (cpath, sri) => {
57-
return lstatAsync(cpath).then(stat => ({cpath, sri, stat}))
58-
}).then(({cpath, sri, stat}) => {
57+
return lstatAsync(cpath).then(stat => ({ cpath, sri, stat }))
58+
}).then(({ cpath, sri, stat }) => {
5959
return pipe(
6060
fs.createReadStream(cpath),
6161
ssri.integrityStream({
@@ -95,7 +95,7 @@ module.exports.hasContent = hasContent
9595
function hasContent (cache, integrity) {
9696
if (!integrity) { return BB.resolve(false) }
9797
return withContentSri(cache, integrity, (cpath, sri) => {
98-
return lstatAsync(cpath).then(stat => ({size: stat.size, sri, stat}))
98+
return lstatAsync(cpath).then(stat => ({ size: stat.size, sri, stat }))
9999
}).catch(err => {
100100
if (err.code === 'ENOENT') { return false }
101101
if (err.code === 'EPERM') {
@@ -114,7 +114,7 @@ function hasContentSync (cache, integrity) {
114114
return withContentSriSync(cache, integrity, (cpath, sri) => {
115115
try {
116116
const stat = fs.lstatSync(cpath)
117-
return {size: stat.size, sri, stat}
117+
return { size: stat.size, sri, stat }
118118
} catch (err) {
119119
if (err.code === 'ENOENT') { return false }
120120
if (err.code === 'EPERM') {
@@ -141,12 +141,12 @@ function withContentSri (cache, integrity, fn) {
141141
} else {
142142
return BB.any(sri[sri.pickAlgorithm()].map(meta => {
143143
return withContentSri(cache, meta, fn)
144-
}, {concurrency: 1}))
144+
}, { concurrency: 1 }))
145145
.catch(err => {
146146
if ([].some.call(err, e => e.code === 'ENOENT')) {
147147
throw Object.assign(
148148
new Error('No matching content found for ' + sri.toString()),
149-
{code: 'ENOENT'}
149+
{ code: 'ENOENT' }
150150
)
151151
} else {
152152
throw err[0]

lib/content/write.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ function write (cache, data, opts) {
3636
}
3737
return BB.using(makeTmp(cache, opts), tmp => (
3838
writeFileAsync(
39-
tmp.target, data, {flag: 'wx'}
39+
tmp.target, data, { flag: 'wx' }
4040
).then(() => (
4141
moveToDestination(tmp, cache, sri, opts)
4242
))
43-
)).then(() => ({integrity: sri, size: data.length}))
43+
)).then(() => ({ integrity: sri, size: data.length }))
4444
}
4545

4646
module.exports.stream = writeStream
@@ -111,7 +111,7 @@ function pipeToTmp (inputStream, cache, tmpTarget, opts, errCheck) {
111111
})
112112
errCheck()
113113
return pipe(inputStream, hashStream, outStream).then(() => {
114-
return {integrity, size}
114+
return { integrity, size }
115115
}).catch(err => {
116116
return rimraf(tmpTarget).then(() => { throw err })
117117
})

lib/entry-index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function insert (cache, key, integrity, opts) {
6464
)
6565
}).then(
6666
() => fixOwner.chownr(bucket, opts.uid, opts.gid)
67-
).catch({code: 'ENOENT'}, () => {
67+
).catch({ code: 'ENOENT' }, () => {
6868
// There's a class of race conditions that happen when things get deleted
6969
// during fixOwner, or between the two mkdirfix/chownr calls.
7070
//
@@ -178,7 +178,7 @@ function lsStream (cache) {
178178
const formatted = formatEntry(cache, entry)
179179
formatted && stream.push(formatted)
180180
}
181-
}).catch({code: 'ENOENT'}, nop)
181+
}).catch({ code: 'ENOENT' }, nop)
182182
})
183183
})
184184
}).then(() => {
@@ -282,8 +282,8 @@ function formatEntry (cache, entry) {
282282

283283
function readdirOrEmpty (dir) {
284284
return readdirAsync(dir)
285-
.catch({code: 'ENOENT'}, () => [])
286-
.catch({code: 'ENOTDIR'}, () => [])
285+
.catch({ code: 'ENOENT' }, () => [])
286+
.catch({ code: 'ENOTDIR' }, () => [])
287287
}
288288

289289
function nop () {

lib/util/fix-owner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function fixOwner (filepath, uid, gid) {
2727
filepath,
2828
typeof uid === 'number' ? uid : process.getuid(),
2929
typeof gid === 'number' ? gid : process.getgid()
30-
).catch({code: 'ENOENT'}, () => null)
30+
).catch({ code: 'ENOENT' }, () => null)
3131
)
3232
}
3333

@@ -65,7 +65,7 @@ function mkdirfix (p, uid, gid, cb) {
6565
if (made) {
6666
return fixOwner(made, uid, gid).then(() => made)
6767
}
68-
}).catch({code: 'EEXIST'}, () => {
68+
}).catch({ code: 'EEXIST' }, () => {
6969
// There's a race in mkdirp!
7070
return fixOwner(p, uid, gid).then(() => null)
7171
})

lib/verify.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function garbageCollect (cache, opts) {
130130
})
131131
})
132132
}
133-
}, {concurrency: opts.concurrency}))
133+
}, { concurrency: opts.concurrency }))
134134
})
135135
})
136136
}
@@ -150,7 +150,7 @@ function verifyContent (filepath, sri) {
150150
contentInfo.valid = false
151151
})
152152
}).then(() => contentInfo)
153-
}).catch({code: 'ENOENT'}, () => ({size: 0, valid: false}))
153+
}).catch({ code: 'ENOENT' }, () => ({ size: 0, valid: false }))
154154
}
155155

156156
function rebuildIndex (cache, opts) {
@@ -183,7 +183,7 @@ function rebuildIndex (cache, opts) {
183183
}
184184
return BB.map(Object.keys(buckets), key => {
185185
return rebuildBucket(cache, buckets[key], stats, opts)
186-
}, {concurrency: opts.concurrency}).then(() => stats)
186+
}, { concurrency: opts.concurrency }).then(() => stats)
187187
})
188188
}
189189

@@ -200,7 +200,7 @@ function rebuildBucket (cache, bucket, stats, opts) {
200200
metadata: entry.metadata,
201201
size: entry.size
202202
}).then(() => { stats.totalEntries++ })
203-
}).catch({code: 'ENOENT'}, () => {
203+
}).catch({ code: 'ENOENT' }, () => {
204204
stats.rejectedEntries++
205205
stats.missingContent++
206206
})

put.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function putData (cache, key, data, opts) {
2828
opts = PutOpts(opts)
2929
return write(cache, data, opts).then(res => {
3030
return index.insert(
31-
cache, key, res.integrity, opts.concat({size: res.size})
31+
cache, key, res.integrity, opts.concat({ size: res.size })
3232
).then(entry => {
3333
if (opts.memoize) {
3434
memo.put(cache, entry, data, opts)
@@ -63,7 +63,7 @@ function putStream (cache, key, opts) {
6363
})
6464
}, cb => {
6565
contentStream.end(() => {
66-
index.insert(cache, key, integrity, opts.concat({size})).then(entry => {
66+
index.insert(cache, key, integrity, opts.concat({ size })).then(entry => {
6767
if (opts.memoize) {
6868
memo.put(cache, entry, Buffer.concat(memoData, memoTotal), opts)
6969
}

test/benchmarks/index.find.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ module.exports = (suite, CACHE) => {
4444
},
4545
onStart () {
4646
const fixture = new Tacks(CacheIndex({
47-
'foo': {key: 'foo'},
48-
'w/e': {key: 'w/e'}
47+
'foo': { key: 'foo' },
48+
'w/e': { key: 'w/e' }
4949
}))
5050
fixture.create(CACHE)
5151
this.fixture = fixture

test/benchmarks/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@ fs.readdir(__dirname, (err, files) => {
7171
require('./' + f)(suite, path.join(CACHE, path.basename(f, '.js')))
7272
}
7373
})
74-
suite.run({async: true})
74+
suite.run({ async: true })
7575
})

test/content.read.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ test('read.stream: returns a stream with cache content data', function (t) {
5454
stream.on('data', function (data) { buf += data })
5555
return BB.join(
5656
finished(stream).then(() => Buffer.from(buf)),
57-
read(CACHE, INTEGRITY, {size: CONTENT.length}),
57+
read(CACHE, INTEGRITY, { size: CONTENT.length }),
5858
(fromStream, fromBulk) => {
5959
t.deepEqual(fromStream, CONTENT, 'stream data checks out')
6060
t.deepEqual(fromBulk, CONTENT, 'promise data checks out')
@@ -65,7 +65,7 @@ test('read.stream: returns a stream with cache content data', function (t) {
6565
test('read: allows hashAlgorithm configuration', function (t) {
6666
const CONTENT = Buffer.from('foobarbaz')
6767
const HASH = 'whirlpool'
68-
const INTEGRITY = ssri.fromData(CONTENT, {algorithms: [HASH]})
68+
const INTEGRITY = ssri.fromData(CONTENT, { algorithms: [HASH] })
6969
const fixture = new Tacks(CacheContent({
7070
[INTEGRITY]: CONTENT
7171
}))
@@ -93,8 +93,8 @@ test('read: errors if content missing', function (t) {
9393
throw new Error('end was called even though stream errored')
9494
})
9595
return BB.join(
96-
finished(stream).catch({code: 'ENOENT'}, err => err),
97-
read(CACHE, 'sha512-whatnot').catch({code: 'ENOENT'}, err => err),
96+
finished(stream).catch({ code: 'ENOENT' }, err => err),
97+
read(CACHE, 'sha512-whatnot').catch({ code: 'ENOENT' }, err => err),
9898
(streamErr, bulkErr) => {
9999
t.equal(streamErr.code, 'ENOENT', 'stream got the right error')
100100
t.equal(bulkErr.code, 'ENOENT', 'bulk got the right error')
@@ -114,8 +114,8 @@ test('read: errors if content fails checksum', function (t) {
114114
throw new Error('end was called even though stream errored')
115115
})
116116
return BB.join(
117-
finished(stream).catch({code: 'EINTEGRITY'}, err => err),
118-
read(CACHE, INTEGRITY).catch({code: 'EINTEGRITY'}, err => err),
117+
finished(stream).catch({ code: 'EINTEGRITY' }, err => err),
118+
read(CACHE, INTEGRITY).catch({ code: 'EINTEGRITY' }, err => err),
119119
(streamErr, bulkErr) => {
120120
t.equal(streamErr.code, 'EINTEGRITY', 'stream got the right error')
121121
t.equal(bulkErr.code, 'EINTEGRITY', 'bulk got the right error')
@@ -135,10 +135,10 @@ test('read: errors if content size does not match size option', function (t) {
135135
throw new Error('end was called even though stream errored')
136136
})
137137
return BB.join(
138-
finished(stream).catch({code: 'EBADSIZE'}, err => err),
138+
finished(stream).catch({ code: 'EBADSIZE' }, err => err),
139139
read(CACHE, INTEGRITY, {
140140
size: CONTENT.length
141-
}).catch({code: 'EBADSIZE'}, err => err),
141+
}).catch({ code: 'EBADSIZE' }, err => err),
142142
(streamErr, bulkErr) => {
143143
t.equal(streamErr.code, 'EBADSIZE', 'stream got the right error')
144144
t.equal(bulkErr.code, 'EBADSIZE', 'bulk got the right error')

0 commit comments

Comments
 (0)