Skip to content

Commit bb52d02

Browse files
committedMar 8, 2018
fix(standard): update to new standard rules
1 parent 5f78812 commit bb52d02

17 files changed

+267
-267
lines changed
 

‎extract.js

+36-36
Original file line numberDiff line numberDiff line change
@@ -24,47 +24,47 @@ function extract (spec, dest, opts) {
2424
return withTarballStream(spec, opts, stream => {
2525
return tryExtract(spec, stream, dest, opts)
2626
})
27-
.then(() => {
28-
if (!opts.resolved) {
29-
const pjson = path.join(dest, 'package.json')
30-
return readFileAsync(pjson, 'utf8')
31-
.then(str => truncateAsync(pjson)
32-
.then(() => appendFileAsync(pjson, str.replace(
33-
/}\s*$/,
34-
`\n,"_resolved": ${
35-
JSON.stringify(opts.resolved || '')
36-
}\n,"_integrity": ${
37-
JSON.stringify(opts.integrity || '')
38-
}\n,"_from": ${
39-
JSON.stringify(spec.toString())
40-
}\n}`
41-
))))
42-
}
43-
})
44-
.then(() => opts.log.silly(
45-
'extract',
46-
`${spec} extracted to ${dest} (${Date.now() - startTime}ms)`
47-
))
27+
.then(() => {
28+
if (!opts.resolved) {
29+
const pjson = path.join(dest, 'package.json')
30+
return readFileAsync(pjson, 'utf8')
31+
.then(str => truncateAsync(pjson)
32+
.then(() => appendFileAsync(pjson, str.replace(
33+
/}\s*$/,
34+
`\n,"_resolved": ${
35+
JSON.stringify(opts.resolved || '')
36+
}\n,"_integrity": ${
37+
JSON.stringify(opts.integrity || '')
38+
}\n,"_from": ${
39+
JSON.stringify(spec.toString())
40+
}\n}`
41+
))))
42+
}
43+
})
44+
.then(() => opts.log.silly(
45+
'extract',
46+
`${spec} extracted to ${dest} (${Date.now() - startTime}ms)`
47+
))
4848
}
4949

5050
function tryExtract (spec, tarStream, dest, opts) {
5151
return new BB((resolve, reject) => {
5252
tarStream.on('error', reject)
5353
setImmediate(resolve)
5454
})
55-
.then(() => rimraf(dest))
56-
.then(() => mkdirp(dest))
57-
.then(() => new BB((resolve, reject) => {
58-
const xtractor = extractStream(spec, dest, opts)
59-
tarStream.on('error', reject)
60-
xtractor.on('error', reject)
61-
xtractor.on('close', resolve)
62-
tarStream.pipe(xtractor)
63-
}))
64-
.catch(err => {
65-
if (err.code === 'EINTEGRITY') {
66-
err.message = `Verification failed while extracting ${spec}:\n${err.message}`
67-
}
68-
throw err
69-
})
55+
.then(() => rimraf(dest))
56+
.then(() => mkdirp(dest))
57+
.then(() => new BB((resolve, reject) => {
58+
const xtractor = extractStream(spec, dest, opts)
59+
tarStream.on('error', reject)
60+
xtractor.on('error', reject)
61+
xtractor.on('close', resolve)
62+
tarStream.pipe(xtractor)
63+
}))
64+
.catch(err => {
65+
if (err.code === 'EINTEGRITY') {
66+
err.message = `Verification failed while extracting ${spec}:\n${err.message}`
67+
}
68+
throw err
69+
})
7070
}

‎lib/fetchers/file.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ Fetcher.impl(fetchFile, {
5252
} else {
5353
let integrity
5454
const cacheWriter = !opts.cache
55-
? BB.resolve(null)
56-
: (pipe(
57-
fs.createReadStream(src),
58-
cacache.put.stream(opts.cache, `pacote:tarball:${src}`, {
59-
integrity: opts.integrity
60-
}).on('integrity', d => { integrity = d })
61-
))
55+
? BB.resolve(null)
56+
: (pipe(
57+
fs.createReadStream(src),
58+
cacache.put.stream(opts.cache, `pacote:tarball:${src}`, {
59+
integrity: opts.integrity
60+
}).on('integrity', d => { integrity = d })
61+
))
6262
return cacheWriter.then(() => {
6363
if (integrity) { stream.emit('integrity', integrity) }
6464
return pipe(fs.createReadStream(src), stream)

‎lib/fetchers/git.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,16 @@ function resolve (url, spec, name, opts) {
135135
const isSemver = !!spec.gitRange
136136
return git.revs(url, opts).then(remoteRefs => {
137137
return isSemver
138-
? pickManifest({
139-
versions: remoteRefs.versions,
140-
'dist-tags': remoteRefs['dist-tags'],
141-
name: name
142-
}, spec.gitRange, opts)
143-
: remoteRefs
144-
? BB.resolve(
145-
remoteRefs.refs[spec.gitCommittish] || remoteRefs.refs[remoteRefs.shas[spec.gitCommittish]]
146-
)
147-
: null
138+
? pickManifest({
139+
versions: remoteRefs.versions,
140+
'dist-tags': remoteRefs['dist-tags'],
141+
name: name
142+
}, spec.gitRange, opts)
143+
: remoteRefs
144+
? BB.resolve(
145+
remoteRefs.refs[spec.gitCommittish] || remoteRefs.refs[remoteRefs.shas[spec.gitCommittish]]
146+
)
147+
: null
148148
})
149149
}
150150

‎lib/fetchers/registry/fetch.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ function logRequest (uri, res, startTime, opts) {
6868

6969
function getCacheMode (opts) {
7070
return opts.offline
71-
? 'only-if-cached'
72-
: opts.preferOffline
73-
? 'force-cache'
74-
: opts.preferOnline
75-
? 'no-cache'
76-
: 'default'
71+
? 'only-if-cached'
72+
: opts.preferOffline
73+
? 'force-cache'
74+
: opts.preferOnline
75+
? 'no-cache'
76+
: 'default'
7777
}
7878

7979
function getHeaders (uri, registry, opts) {

‎lib/fetchers/registry/manifest.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ function manifest (spec, opts) {
2828

2929
function metadataUrl (registry, name) {
3030
const normalized = registry.slice(-1) !== '/'
31-
? registry + '/'
32-
: registry
31+
? registry + '/'
32+
: registry
3333
return url.resolve(normalized, name)
3434
}
3535

‎lib/fetchers/registry/tarball.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,20 @@ function fromManifest (manifest, spec, opts) {
6060
integrity: manifest._integrity,
6161
algorithms: [
6262
manifest._integrity
63-
? ssri.parse(manifest._integrity).pickAlgorithm()
64-
: 'sha1'
63+
? ssri.parse(manifest._integrity).pickAlgorithm()
64+
: 'sha1'
6565
],
6666
spec
6767
}, opts))
68-
.then(res => {
69-
const hash = res.headers.get('x-local-cache-hash')
70-
if (hash) {
71-
stream.emit('integrity', decodeURIComponent(hash))
72-
}
73-
res.body.on('error', err => stream.emit('error', err))
74-
res.body.pipe(stream)
75-
})
76-
.catch(err => stream.emit('error', err))
68+
.then(res => {
69+
const hash = res.headers.get('x-local-cache-hash')
70+
if (hash) {
71+
stream.emit('integrity', decodeURIComponent(hash))
72+
}
73+
res.body.on('error', err => stream.emit('error', err))
74+
res.body.pipe(stream)
75+
})
76+
.catch(err => stream.emit('error', err))
7777
return stream
7878
}
7979

‎lib/finalize-manifest.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ function finalizeManifest (pkg, spec, opts) {
3838
opts = optCheck(opts)
3939

4040
const cachedManifest = (opts.cache && key && !opts.preferOnline && !opts.fullMetadata)
41-
? cacache.get.info(opts.cache, key, opts)
42-
: BB.resolve(null)
41+
? cacache.get.info(opts.cache, key, opts)
42+
: BB.resolve(null)
4343

4444
return cachedManifest.then(cached => {
4545
if (cached && cached.metadata.manifest) {
4646
return new Manifest(cached.metadata.manifest)
4747
} else {
4848
return tarballedProps(pkg, spec, opts).then(props => {
4949
return pkg && pkg.name
50-
? new Manifest(pkg, props, opts.fullMetadata)
51-
: new Manifest(props, null, opts.fullMetadata)
50+
? new Manifest(pkg, props, opts.fullMetadata)
51+
: new Manifest(props, null, opts.fullMetadata)
5252
}).then(manifest => {
5353
const cacheKey = key || finalKey(manifest, spec)
5454
if (!opts.cache || !cacheKey) {
@@ -169,8 +169,8 @@ function tarballedProps (pkg, spec, opts) {
169169
// to add to bin
170170
if (paths && paths.length) {
171171
const dirBin = mani
172-
? (mani && mani.directories && mani.directories.bin)
173-
: (pkg && pkg.directories && pkg.directories.bin)
172+
? (mani && mani.directories && mani.directories.bin)
173+
: (pkg && pkg.directories && pkg.directories.bin)
174174
if (dirBin) {
175175
extraProps.bin = {}
176176
paths.forEach(filePath => {

‎lib/util/git.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,10 @@ const REFS_HEADS = 'refs/heads/'
258258
const HEAD = 'HEAD'
259259
function refType (ref) {
260260
return ref.indexOf(REFS_TAGS) !== -1
261-
? 'tag'
262-
: ref.indexOf(REFS_HEADS) !== -1
263-
? 'branch'
264-
: ref.endsWith(HEAD)
265-
? 'head'
266-
: 'other'
261+
? 'tag'
262+
: ref.indexOf(REFS_HEADS) !== -1
263+
? 'branch'
264+
: ref.endsWith(HEAD)
265+
? 'head'
266+
: 'other'
267267
}

‎lib/util/opt-check.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ function PacoteOptions (opts) {
4545
this.fullMetadata = opts.fullMetadata
4646
this.alwaysAuth = opts.alwaysAuth
4747
this.includeDeprecated = opts.includeDeprecated == null
48-
? true
49-
: opts.includeDeprecated
48+
? true
49+
: opts.includeDeprecated
5050

5151
this.dirPacker = opts.dirPacker || null
5252

‎lib/util/pack-dir.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ function packDir (manifest, label, dir, target, opts) {
1414
opts = optCheck(opts)
1515

1616
const packer = opts.dirPacker
17-
? BB.resolve(opts.dirPacker(manifest, dir))
18-
: mkPacker(dir)
17+
? BB.resolve(opts.dirPacker(manifest, dir))
18+
: mkPacker(dir)
1919

2020
if (!opts.cache) {
2121
return packer.then(packer => pipe(packer, target))

‎lib/with-tarball-stream.js

+85-85
Original file line numberDiff line numberDiff line change
@@ -27,107 +27,107 @@ function withTarballStream (spec, opts, streamHandler) {
2727
opts.resolved &&
2828
opts.resolved.startsWith('file:')
2929
)
30-
? BB.try(() => {
30+
? BB.try(() => {
3131
// NOTE - this is a special shortcut! Packages installed as files do not
3232
// have a `resolved` field -- this specific case only occurs when you have,
3333
// say, a git dependency or a registry dependency that you've packaged into
3434
// a local file, and put that file: spec in the `resolved` field.
35-
opts.log.silly('pacote', `trying ${spec} by local file: ${opts.resolved}`)
36-
const file = path.resolve(opts.where || '.', opts.resolved.substr(5))
37-
return statAsync(file)
38-
.then(() => {
39-
const verifier = ssri.integrityStream({integrity: opts.integrity})
40-
const stream = fs.createReadStream(file)
41-
.on('error', err => verifier.emit('error', err))
42-
.pipe(verifier)
43-
return streamHandler(stream)
44-
})
45-
.catch(err => {
46-
if (err.code === 'EINTEGRITY') {
47-
opts.log.warn('pacote', `EINTEGRITY while extracting ${spec} from ${file}.You will have to recreate the file.`)
48-
opts.log.verbose('pacote', `EINTEGRITY for ${spec}: ${err.message}`)
49-
}
50-
throw err
35+
opts.log.silly('pacote', `trying ${spec} by local file: ${opts.resolved}`)
36+
const file = path.resolve(opts.where || '.', opts.resolved.substr(5))
37+
return statAsync(file)
38+
.then(() => {
39+
const verifier = ssri.integrityStream({integrity: opts.integrity})
40+
const stream = fs.createReadStream(file)
41+
.on('error', err => verifier.emit('error', err))
42+
.pipe(verifier)
43+
return streamHandler(stream)
44+
})
45+
.catch(err => {
46+
if (err.code === 'EINTEGRITY') {
47+
opts.log.warn('pacote', `EINTEGRITY while extracting ${spec} from ${file}.You will have to recreate the file.`)
48+
opts.log.verbose('pacote', `EINTEGRITY for ${spec}: ${err.message}`)
49+
}
50+
throw err
51+
})
5152
})
52-
})
53-
: BB.reject(Object.assign(new Error('no file!'), {code: 'ENOENT'}))
53+
: BB.reject(Object.assign(new Error('no file!'), {code: 'ENOENT'}))
5454

5555
const tryDigest = tryFile
56-
.catch(err => {
57-
if (
58-
opts.preferOnline ||
56+
.catch(err => {
57+
if (
58+
opts.preferOnline ||
5959
!opts.cache ||
6060
!opts.integrity ||
6161
!RETRIABLE_ERRORS.has(err.code)
62-
) {
63-
throw err
64-
} else {
65-
opts.log.silly('tarball', `trying ${spec} by hash: ${opts.integrity}`)
66-
const stream = cacache.get.stream.byDigest(
67-
opts.cache, opts.integrity, opts
68-
)
69-
stream.once('error', err => stream.on('newListener', (ev, l) => {
70-
if (ev === 'error') { l(err) }
71-
}))
72-
return streamHandler(stream)
73-
.catch(err => {
74-
if (err.code === 'EINTEGRITY' || err.code === 'Z_DATA_ERROR') {
75-
opts.log.warn('tarball', `cached data for ${spec} (${opts.integrity}) seems to be corrupted. Refreshing cache.`)
76-
return cleanUpCached(opts.cache, opts.integrity, opts)
77-
.then(() => { throw err })
78-
} else {
79-
throw err
80-
}
81-
})
82-
}
83-
})
62+
) {
63+
throw err
64+
} else {
65+
opts.log.silly('tarball', `trying ${spec} by hash: ${opts.integrity}`)
66+
const stream = cacache.get.stream.byDigest(
67+
opts.cache, opts.integrity, opts
68+
)
69+
stream.once('error', err => stream.on('newListener', (ev, l) => {
70+
if (ev === 'error') { l(err) }
71+
}))
72+
return streamHandler(stream)
73+
.catch(err => {
74+
if (err.code === 'EINTEGRITY' || err.code === 'Z_DATA_ERROR') {
75+
opts.log.warn('tarball', `cached data for ${spec} (${opts.integrity}) seems to be corrupted. Refreshing cache.`)
76+
return cleanUpCached(opts.cache, opts.integrity, opts)
77+
.then(() => { throw err })
78+
} else {
79+
throw err
80+
}
81+
})
82+
}
83+
})
8484

8585
const trySpec = tryDigest
86-
.catch(err => {
87-
if (!RETRIABLE_ERRORS.has(err.code)) {
86+
.catch(err => {
87+
if (!RETRIABLE_ERRORS.has(err.code)) {
8888
// If it's not one of our retriable errors, bail out and give up.
89-
throw err
90-
} else {
91-
opts.log.silly(
92-
'tarball',
93-
`no local data for ${spec}. Extracting by manifest.`
94-
)
95-
return BB.resolve(retry((tryAgain, attemptNum) => {
96-
const tardata = fetch.tarball(spec, opts)
97-
if (!opts.resolved) {
98-
tardata.on('manifest', m => {
99-
opts.resolved = m._resolved
100-
})
101-
tardata.on('integrity', i => {
102-
opts.integrity = i
103-
})
104-
}
105-
return BB.try(() => streamHandler(tardata))
106-
.catch(err => {
107-
// Retry once if we have a cache, to clear up any weird conditions.
108-
// Don't retry network errors, though -- make-fetch-happen has already
109-
// taken care of making sure we're all set on that front.
110-
if (opts.cache && err.code && !err.code.match(/^E\d{3}$/)) {
111-
if (err.code === 'EINTEGRITY' || err.code === 'Z_DATA_ERROR') {
112-
opts.log.warn('tarball', `tarball data for ${spec} (${opts.integrity}) seems to be corrupted. Trying one more time.`)
113-
}
114-
return cleanUpCached(opts.cache, err.sri, opts)
115-
.then(() => tryAgain(err))
116-
} else {
117-
throw err
89+
throw err
90+
} else {
91+
opts.log.silly(
92+
'tarball',
93+
`no local data for ${spec}. Extracting by manifest.`
94+
)
95+
return BB.resolve(retry((tryAgain, attemptNum) => {
96+
const tardata = fetch.tarball(spec, opts)
97+
if (!opts.resolved) {
98+
tardata.on('manifest', m => {
99+
opts.resolved = m._resolved
100+
})
101+
tardata.on('integrity', i => {
102+
opts.integrity = i
103+
})
118104
}
119-
})
120-
}, {retries: 1}))
121-
}
122-
})
105+
return BB.try(() => streamHandler(tardata))
106+
.catch(err => {
107+
// Retry once if we have a cache, to clear up any weird conditions.
108+
// Don't retry network errors, though -- make-fetch-happen has already
109+
// taken care of making sure we're all set on that front.
110+
if (opts.cache && err.code && !err.code.match(/^E\d{3}$/)) {
111+
if (err.code === 'EINTEGRITY' || err.code === 'Z_DATA_ERROR') {
112+
opts.log.warn('tarball', `tarball data for ${spec} (${opts.integrity}) seems to be corrupted. Trying one more time.`)
113+
}
114+
return cleanUpCached(opts.cache, err.sri, opts)
115+
.then(() => tryAgain(err))
116+
} else {
117+
throw err
118+
}
119+
})
120+
}, {retries: 1}))
121+
}
122+
})
123123

124124
return trySpec
125-
.catch(err => {
126-
if (err.code === 'EINTEGRITY') {
127-
err.message = `Verification failed while extracting ${spec}:\n${err.message}`
128-
}
129-
throw err
130-
})
125+
.catch(err => {
126+
if (err.code === 'EINTEGRITY') {
127+
err.message = `Verification failed while extracting ${spec}:\n${err.message}`
128+
}
129+
throw err
130+
})
131131
}
132132

133133
function cleanUpCached (cachePath, integrity, opts) {

‎tarball.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function tarballStream (spec, opts) {
4545
})
4646
}
4747
})
48-
.catch(err => output.emit('error', err))
48+
.catch(err => output.emit('error', err))
4949
return output
5050
}
5151

@@ -54,14 +54,14 @@ function tarballToFile (spec, dest, opts) {
5454
opts = optCheck(opts)
5555
spec = npa(spec, opts.where)
5656
return mkdirp(path.dirname(dest))
57-
.then(() => withTarballStream(spec, opts, stream => {
58-
return rimraf(dest)
59-
.then(() => new BB((resolve, reject) => {
60-
const writer = fs.createWriteStream(dest)
61-
stream.on('error', reject)
62-
writer.on('error', reject)
63-
writer.on('close', resolve)
64-
stream.pipe(writer)
57+
.then(() => withTarballStream(spec, opts, stream => {
58+
return rimraf(dest)
59+
.then(() => new BB((resolve, reject) => {
60+
const writer = fs.createWriteStream(dest)
61+
stream.on('error', reject)
62+
writer.on('error', reject)
63+
writer.on('close', resolve)
64+
stream.pipe(writer)
65+
}))
6566
}))
66-
}))
6767
}

‎test/extract.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,25 @@ test('opts.resolved `file:` specs bypass further resolution', t => {
3838
const dest = path.join(testDir, 'foo')
3939
let sri
4040
return mockTar(pkg)
41-
.then(tarData => {
42-
sri = ssri.fromData(tarData)
43-
const opts = Object.assign({}, OPTS, {
44-
integrity: sri,
45-
resolved: 'file:foo-1.2.3.tgz',
46-
where: testDir
41+
.then(tarData => {
42+
sri = ssri.fromData(tarData)
43+
const opts = Object.assign({}, OPTS, {
44+
integrity: sri,
45+
resolved: 'file:foo-1.2.3.tgz',
46+
where: testDir
47+
})
48+
return fs.writeFileAsync(path.join(testDir, 'foo-1.2.3.tgz'), tarData)
49+
.then(() => extract('foo@1.2.3', dest, opts))
4750
})
48-
return fs.writeFileAsync(path.join(testDir, 'foo-1.2.3.tgz'), tarData)
49-
.then(() => extract('foo@1.2.3', dest, opts))
50-
})
51-
.then(() => fs.readFileAsync(path.join(dest, 'index.js'), 'utf8'))
52-
.then(data => t.equal(data, pkg['index.js'], 'index.js extracted ok'))
53-
.then(() => fs.readFileAsync(path.join(dest, 'package.json'), 'utf8'))
54-
.then(JSON.parse)
55-
.then(json => t.deepEqual(json, {
56-
name: 'foo',
57-
version: '1.2.3',
58-
_resolved: 'file:foo-1.2.3.tgz',
59-
_integrity: sri.toString(),
60-
_from: 'foo@1.2.3'
61-
}, 'package.json written ok with extra _fields'))
51+
.then(() => fs.readFileAsync(path.join(dest, 'index.js'), 'utf8'))
52+
.then(data => t.equal(data, pkg['index.js'], 'index.js extracted ok'))
53+
.then(() => fs.readFileAsync(path.join(dest, 'package.json'), 'utf8'))
54+
.then(JSON.parse)
55+
.then(json => t.deepEqual(json, {
56+
name: 'foo',
57+
version: '1.2.3',
58+
_resolved: 'file:foo-1.2.3.tgz',
59+
_integrity: sri.toString(),
60+
_from: 'foo@1.2.3'
61+
}, 'package.json written ok with extra _fields'))
6262
})

‎test/git.manifest.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ test('get manifest from package.json in git clone', {
4242
fixture.create(testDir)
4343
return BB.using(gitMock({cwd: path.join(testDir, 'foo')}), srv => {
4444
return manifest(`bar@git://127.0.0.1:${srv.port}/`, OPTS)
45-
.then(mani => {
46-
t.similar(mani, {
47-
name: 'foo',
48-
version: '1.2.3',
49-
_resolved: new RegExp(`git://127.0.0.1:${srv.port}/#[a-f0-9]{40}$`),
50-
_shasum: null,
51-
_shrinkwrap: null,
52-
_id: 'foo@1.2.3'
53-
}, 'manifest fetched correctly')
54-
})
45+
.then(mani => {
46+
t.similar(mani, {
47+
name: 'foo',
48+
version: '1.2.3',
49+
_resolved: new RegExp(`git://127.0.0.1:${srv.port}/#[a-f0-9]{40}$`),
50+
_shasum: null,
51+
_shrinkwrap: null,
52+
_id: 'foo@1.2.3'
53+
}, 'manifest fetched correctly')
54+
})
5555
})
5656
})
5757

‎test/tarball.js

+38-38
Original file line numberDiff line numberDiff line change
@@ -253,51 +253,51 @@ test('(toFile) tarball by manifest if digest provided but no cache content found
253253
test('opts.resolved shortcut for `file:` skips metadata and cache', t => {
254254
clearMemoized()
255255
return mockTar(PKG)
256-
.then(tarData => {
257-
const fixture = new Tacks(Dir({
258-
resolved: Dir({
259-
'foo.tgz': File(tarData)
256+
.then(tarData => {
257+
const fixture = new Tacks(Dir({
258+
resolved: Dir({
259+
'foo.tgz': File(tarData)
260+
})
261+
}))
262+
fixture.create(CACHE)
263+
const opts = Object.assign({}, OPTS, {
264+
integrity: BASE.dist.integrity,
265+
resolved: 'file:' + path.join(CACHE, 'resolved', 'foo.tgz')
260266
})
261-
}))
262-
fixture.create(CACHE)
263-
const opts = Object.assign({}, OPTS, {
264-
integrity: BASE.dist.integrity,
265-
resolved: 'file:' + path.join(CACHE, 'resolved', 'foo.tgz')
267+
return tarball('foo@1.0.0', opts)
268+
.then(data => {
269+
t.deepEqual(data, tarData, 'fetched from locally-resolved file')
270+
})
271+
.then(() => tarball('bar@git://github.com/foo/bar', opts))
272+
.then(data => {
273+
t.deepEqual(data, tarData, 'non-registry types use opts.resolved too')
274+
})
266275
})
267-
return tarball('foo@1.0.0', opts)
268-
.then(data => {
269-
t.deepEqual(data, tarData, 'fetched from locally-resolved file')
270-
})
271-
.then(() => tarball('bar@git://github.com/foo/bar', opts))
272-
.then(data => {
273-
t.deepEqual(data, tarData, 'non-registry types use opts.resolved too')
274-
})
275-
})
276276
})
277277

278278
test('(stream) opts.resolved shortcut for `file:`', t => {
279279
clearMemoized()
280280
return mockTar(PKG)
281-
.then(tarData => {
282-
const fixture = new Tacks(Dir({
283-
resolved: Dir({
284-
'foo.tgz': File(tarData)
281+
.then(tarData => {
282+
const fixture = new Tacks(Dir({
283+
resolved: Dir({
284+
'foo.tgz': File(tarData)
285+
})
286+
}))
287+
fixture.create(CACHE)
288+
const opts = Object.assign({}, OPTS, {
289+
integrity: BASE.dist.integrity,
290+
resolved: 'file:' + path.join(CACHE, 'resolved', 'foo.tgz')
285291
})
286-
}))
287-
fixture.create(CACHE)
288-
const opts = Object.assign({}, OPTS, {
289-
integrity: BASE.dist.integrity,
290-
resolved: 'file:' + path.join(CACHE, 'resolved', 'foo.tgz')
292+
return getStream.buffer(tarball.stream('foo@1.0.0', opts))
293+
.then(data => {
294+
t.deepEqual(data, tarData, 'fetched from locally-resolved file')
295+
})
296+
.then(() => getStream.buffer(
297+
tarball.stream('bar@git://github.com/foo/bar', opts))
298+
)
299+
.then(data => {
300+
t.deepEqual(data, tarData, 'non-registry types use opts.resolved too')
301+
})
291302
})
292-
return getStream.buffer(tarball.stream('foo@1.0.0', opts))
293-
.then(data => {
294-
t.deepEqual(data, tarData, 'fetched from locally-resolved file')
295-
})
296-
.then(() => getStream.buffer(
297-
tarball.stream('bar@git://github.com/foo/bar', opts))
298-
)
299-
.then(data => {
300-
t.deepEqual(data, tarData, 'non-registry types use opts.resolved too')
301-
})
302-
})
303303
})

‎test/util/git.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@ function daemon (opts) {
5656
srv.once('exit', cb)
5757
srv.once('error', cb)
5858
})
59-
.then(srv => {
60-
return srv
61-
}, e => {
62-
if (stderr.match(/already in use/i)) {
63-
return tryAgain(e)
64-
} else {
65-
throw e
66-
}
67-
})
59+
.then(srv => {
60+
return srv
61+
}, e => {
62+
if (stderr.match(/already in use/i)) {
63+
return tryAgain(e)
64+
} else {
65+
throw e
66+
}
67+
})
6868
}, { factor: 1, minTimeout: 100 }))
69-
.disposer(srv => BB.fromNode(cb => {
70-
srv.on('error', cb)
71-
srv.on('close', cb)
72-
srv.kill()
73-
}))
69+
.disposer(srv => BB.fromNode(cb => {
70+
srv.on('error', cb)
71+
srv.on('close', cb)
72+
srv.kill()
73+
}))
7474
}

‎test/util/mock-tarball.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ function makeTarball (files, opts) {
2525
uname: entry.uname,
2626
gname: entry.gname
2727
}, typeof files[filename] === 'string'
28-
? files[filename]
29-
: files[filename].data)
28+
? files[filename]
29+
: files[filename].data)
3030
})
3131
pack.finalize()
3232
return BB.try(() => {

0 commit comments

Comments
 (0)
Please sign in to comment.