Skip to content

Commit

Permalink
tap@15, remove require-inject
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Apr 13, 2021
1 parent 1430efa commit 99738cd
Show file tree
Hide file tree
Showing 16 changed files with 2,566 additions and 2,038 deletions.
4,413 changes: 2,405 additions & 2,008 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
},
"tap": {
"timeout": 300,
"check-coverage": true,
"coverage-map": "map.js",
"esm": false
"coverage-map": "map.js"
},
"devDependencies": {
"mutate-fs": "^2.1.1",
"npm-registry-mock": "^1.3.1",
"require-inject": "^1.4.4",
"tap": "^14.11.0"
"tap": "^15.0.2"
},
"files": [
"lib/**/*.js"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,39 @@ Object {
"exitlog": Array [],
"loglog": Array [
Array [
"Pacote - The JavaScript Package Handler, v{VERSION}\\n\\nUsage:\\n\\n pacote resolve <spec>\\n Resolve a specifier and output the fully resolved target\\n Returns integrity and from if '--long' flag is set.\\n\\n pacote manifest <spec>\\n Fetch a manifest and print to stdout\\n\\n pacote packument <spec>\\n Fetch a full packument and print to stdout\\n\\n pacote tarball <spec> [<filename>]\\n Fetch a package tarball and save to <filename>\\n If <filename> is missing or '-', the tarball will be streamed to stdout.\\n\\n pacote extract <spec> <folder>\\n Extract a package to the destination folder.\\n\\nConfiguration values all match the names of configs passed to npm, or\\noptions passed to Pacote. Additional flags for this executable:\\n\\n --long Print an object from 'resolve', including integrity and spec.\\n --json Print result objects as JSON rather than node's default.\\n (This is the default if stdout is not a TTY.)\\n --help -h Print this helpful text.\\n\\nFor example '--cache=/path/to/folder' will use that folder as the cache.\\n",
String(
Pacote - The JavaScript Package Handler, v{VERSION}
Usage:
pacote resolve <spec>
Resolve a specifier and output the fully resolved target
Returns integrity and from if '--long' flag is set.
pacote manifest <spec>
Fetch a manifest and print to stdout
pacote packument <spec>
Fetch a full packument and print to stdout
pacote tarball <spec> [<filename>]
Fetch a package tarball and save to <filename>
If <filename> is missing or '-', the tarball will be streamed to stdout.
pacote extract <spec> <folder>
Extract a package to the destination folder.
Configuration values all match the names of configs passed to npm, or
options passed to Pacote. Additional flags for this executable:
--long Print an object from 'resolve', including integrity and spec.
--json Print result objects as JSON rather than node's default.
(This is the default if stdout is not a TTY.)
--help -h Print this helpful text.
For example '--cache=/path/to/folder' will use that folder as the cache.
),
],
],
}
Expand All @@ -24,7 +56,39 @@ Object {
"bad command: blerg",
],
Array [
"Pacote - The JavaScript Package Handler, v{VERSION}\\n\\nUsage:\\n\\n pacote resolve <spec>\\n Resolve a specifier and output the fully resolved target\\n Returns integrity and from if '--long' flag is set.\\n\\n pacote manifest <spec>\\n Fetch a manifest and print to stdout\\n\\n pacote packument <spec>\\n Fetch a full packument and print to stdout\\n\\n pacote tarball <spec> [<filename>]\\n Fetch a package tarball and save to <filename>\\n If <filename> is missing or '-', the tarball will be streamed to stdout.\\n\\n pacote extract <spec> <folder>\\n Extract a package to the destination folder.\\n\\nConfiguration values all match the names of configs passed to npm, or\\noptions passed to Pacote. Additional flags for this executable:\\n\\n --long Print an object from 'resolve', including integrity and spec.\\n --json Print result objects as JSON rather than node's default.\\n (This is the default if stdout is not a TTY.)\\n --help -h Print this helpful text.\\n\\nFor example '--cache=/path/to/folder' will use that folder as the cache.\\n",
String(
Pacote - The JavaScript Package Handler, v{VERSION}
Usage:
pacote resolve <spec>
Resolve a specifier and output the fully resolved target
Returns integrity and from if '--long' flag is set.
pacote manifest <spec>
Fetch a manifest and print to stdout
pacote packument <spec>
Fetch a full packument and print to stdout
pacote tarball <spec> [<filename>]
Fetch a package tarball and save to <filename>
If <filename> is missing or '-', the tarball will be streamed to stdout.
pacote extract <spec> <folder>
Extract a package to the destination folder.
Configuration values all match the names of configs passed to npm, or
options passed to Pacote. Additional flags for this executable:
--long Print an object from 'resolve', including integrity and spec.
--json Print result objects as JSON rather than node's default.
(This is the default if stdout is not a TTY.)
--help -h Print this helpful text.
For example '--cache=/path/to/folder' will use that folder as the cache.
),
],
],
"exitlog": Array [],
Expand All @@ -38,7 +102,22 @@ Object {
"exitlog": Array [],
"loglog": Array [
Array [
"{\\n \\"method\\": \\"extract\\",\\n \\"spec\\": \\"npm@latest-6\\",\\n \\"dest\\": \\"folder\\",\\n \\"conf\\": {\\n \\"_\\": [\\n \\"extract\\",\\n \\"npm@latest-6\\",\\n \\"folder\\"\\n ],\\n \\"cache\\": \\"{HOME}/.npm/_cacache\\",\\n \\"json\\": true\\n }\\n}",
String(
{
"method": "extract",
"spec": "npm@latest-6",
"dest": "folder",
"conf": {
"_": [
"extract",
"npm@latest-6",
"folder"
],
"cache": "{HOME}/.npm/_cacache",
"json": true
}
}
),
],
],
}
Expand Down Expand Up @@ -75,7 +154,22 @@ Object {
"exitlog": Array [],
"loglog": Array [
Array [
"{\\n \\"method\\": \\"manifest\\",\\n \\"spec\\": \\"bar@foo\\",\\n \\"conf\\": {\\n \\"_\\": [\\n \\"manifest\\",\\n \\"bar@foo\\"\\n ],\\n \\"cache\\": \\"{HOME}/.npm/_cacache\\"\\n },\\n \\"_resolved\\": \\"manifest resolved\\",\\n \\"_integrity\\": \\"manifest integrity\\",\\n \\"_from\\": \\"manifest from\\"\\n}",
String(
{
"method": "manifest",
"spec": "bar@foo",
"conf": {
"_": [
"manifest",
"bar@foo"
],
"cache": "{HOME}/.npm/_cacache"
},
"_resolved": "manifest resolved",
"_integrity": "manifest integrity",
"_from": "manifest from"
}
),
],
],
}
Expand All @@ -87,7 +181,19 @@ Object {
"exitlog": Array [],
"loglog": Array [
Array [
"{\\n \\"method\\": \\"packument\\",\\n \\"spec\\": \\"paku@mint\\",\\n \\"conf\\": {\\n \\"_\\": [\\n \\"packument\\",\\n \\"paku@mint\\"\\n ],\\n \\"cache\\": \\"{HOME}/.npm/_cacache\\"\\n }\\n}",
String(
{
"method": "packument",
"spec": "paku@mint",
"conf": {
"_": [
"packument",
"paku@mint"
],
"cache": "{HOME}/.npm/_cacache"
}
}
),
],
],
}
Expand All @@ -113,7 +219,13 @@ Object {
"exitlog": Array [],
"loglog": Array [
Array [
"{\\n \\"resolved\\": \\"manifest resolved\\",\\n \\"integrity\\": \\"manifest integrity\\",\\n \\"from\\": \\"manifest from\\"\\n}",
String(
{
"resolved": "manifest resolved",
"integrity": "manifest integrity",
"from": "manifest from"
}
),
],
],
}
Expand All @@ -125,7 +237,19 @@ Object {
"exitlog": Array [],
"loglog": Array [
Array [
"{\\n \\"method\\": \\"resolve\\",\\n \\"spec\\": \\"foo@bar\\",\\n \\"conf\\": {\\n \\"_\\": [\\n \\"resolve\\",\\n \\"foo@bar\\"\\n ],\\n \\"cache\\": \\"{HOME}/.npm/_cacache\\"\\n }\\n}",
String(
{
"method": "resolve",
"spec": "foo@bar",
"conf": {
"_": [
"resolve",
"foo@bar"
],
"cache": "{HOME}/.npm/_cacache"
}
}
),
],
],
}
Expand Down Expand Up @@ -161,7 +285,21 @@ Object {
"exitlog": Array [],
"loglog": Array [
Array [
"{\\n \\"method\\": \\"tarball\\",\\n \\"spec\\": \\"tar@ball\\",\\n \\"file\\": \\"file.tgz\\",\\n \\"conf\\": {\\n \\"_\\": [\\n \\"tarball\\",\\n \\"tar@ball\\",\\n \\"file.tgz\\"\\n ],\\n \\"cache\\": \\"{HOME}/.npm/_cacache\\"\\n }\\n}",
String(
{
"method": "tarball",
"spec": "tar@ball",
"file": "file.tgz",
"conf": {
"_": [
"tarball",
"tar@ball",
"file.tgz"
],
"cache": "{HOME}/.npm/_cacache"
}
}
),
],
],
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions test/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,10 @@ t.test('main', t => {
const exitlog = []
process.exit = code => exitlog.push(code)

t.beforeEach(cb => {
t.beforeEach(() => {
errorlog.length = 0
loglog.length = 0
exitlog.length = 0
cb()
})

Object.defineProperty(process.stdout, 'isTTY', { value: false })
Expand Down
6 changes: 3 additions & 3 deletions test/dir.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const requireInject = require('require-inject')
const runScript = require('@npmcli/run-script')
const RUNS = []
const DirFetcher = requireInject('../lib/dir.js', {
const t = require('tap')

const DirFetcher = t.mock('../lib/dir.js', {
'@npmcli/run-script': (opts) => {
RUNS.push(opts)
// don't actually inherit or print banner in the test, though.
return runScript({ ...opts, stdio: 'pipe', banner: false })
},
})

const t = require('tap')
const npa = require('npm-package-arg')
const fs = require('fs')
const { promisify } = require('util')
Expand Down
7 changes: 3 additions & 4 deletions test/fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ t.cleanSnapshot = s => s.split(process.cwd()).join('{CWD}')

const npa = require('npm-package-arg')
const { promisify } = require('util')
const mkdirp = require('mkdirp')

const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved')

Expand Down Expand Up @@ -67,7 +66,7 @@ t.test('snapshot the npmInstallCmd and npmInstallConfig', async t => {
t.equal(def.npmBin, 'npm', 'use default npm bin')
t.matchSnapshot(def.npmInstallCmd, 'default install cmd')
t.matchSnapshot(def.npmCliConfig, 'default install config')
t.notEqual(basename(def.npmCliConfig[0]), '_cacache',
t.not(basename(def.npmCliConfig[0]), '_cacache',
'do not have a _cacache folder on cache config passed to npm cli')
t.equal(basename(def.cache), '_cacache',
'have a _cacache folder on default pacote config itself')
Expand Down Expand Up @@ -180,7 +179,7 @@ t.test('extract', t => {
}).extract(target + '/cached'))
.then(check('cached'))
.then(!fakeSudo ? () => {} : () => {
t.notEqual(process.chownLog.length, 0, 'did some chowns')
t.not(process.chownLog.length, 0, 'did some chowns')
const log = { uid: process.realUid, gid: process.getgid() }
process.chownLog.forEach(entry => t.match(entry, log, 'chowned to me'))
process.chownLog.length = 0
Expand Down Expand Up @@ -480,7 +479,7 @@ t.test('set integrity, pick default algo', t => {
}
const f = new FileFetcher('pkg.tgz', opts)
t.equal(f.pickIntegrityAlgorithm(), 'sha512')
t.isa(f.opts.integrity, Object)
t.type(f.opts.integrity, Object)
const i = f.integrity
f.integrity = null
t.equal(f.integrity, i, 'cannot remove integrity')
Expand Down
7 changes: 3 additions & 4 deletions test/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ const abbrev = resolve(fixtures, 'abbrev-1.1.1.tgz')
const prepIgnore = resolve(fixtures, 'prepare-requires-gitignore-1.2.3.tgz')
const npa = require('npm-package-arg')

t.saveFixture = true
const me = t.testdir({
repo: {},
cache: {},
Expand Down Expand Up @@ -323,7 +322,7 @@ t.test('setup', { bail: true }, t => {
return res.end('not found')
}
})
t.parent.parent.tearDown(() => s.close())
t.parent.parent.teardown(() => s.close())
s.listen(httpPort, () => t.end())
})

Expand All @@ -339,7 +338,7 @@ t.test('basic stuff', async t => {
await g.resolve().then(resolved => t.equal(resolved, r.resolved))
const s = new GitFetcher(remote + '#semver:1.x', {cache})
t.equal(s.resolved, null)
await s.resolve().then(resolved => t.notEqual(resolved, r.resolved))
await s.resolve().then(resolved => t.not(resolved, r.resolved))

const gx = await g.extract(me + '/g')
const rx = await r.extract(me + '/r')
Expand Down Expand Up @@ -514,7 +513,7 @@ t.test('fetch a weird ref', t => {
head3 = result.resolved.split('#').pop()
t.match(result.resolved, /^git\+git:\/\/127\.0\.0\.1:[0-9]+\/repo#[a-z0-9]{40}$/,
'got git url as resolved value')
t.notEqual(result.resolved, `${remoteHosted}#${REPO_HEAD}`,
t.not(result.resolved, `${remoteHosted}#${REPO_HEAD}`,
'git url for HEAD~3 is not the same as HEAD')
}))

Expand Down
1 change: 0 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const weirdspec = `file:${relative(process.cwd(), weird)}`
const ignore = resolve(__dirname, 'fixtures/ignore-pkg.tgz')
const ignorespec = `file:${relative(process.cwd(), ignore)}`

const mkdirp = require('mkdirp')
const me = t.testdir()

t.cleanSnapshot = str => str
Expand Down
6 changes: 3 additions & 3 deletions test/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ t.test('underscore, no tag or version', t => {
return f.manifest().then(m2 => t.equal(m, m2, 'manifest cached'))
})
.then(() => f.extract(me + '/underscore'))
.then(result => t.deepEqual(result, {
.then(result => t.same(result, {
resolved: `${registry}underscore/-/underscore-1.5.1.tgz`,
integrity: 'sha1-0r3oF9F2/63olKtxRY5oKhS4bck= sha512-yOc7VukmA45a1D6clUn1mD7Mbc9LcVYAQEXNKSTblzha59hSFJ6cAt90JDoxh05GQnTPI9nk4wjT/I8C/nAMPw==',
from: "underscore@",
Expand All @@ -78,7 +78,7 @@ t.test('scoped, no tag or version', t => {
return f.resolve().then(r => t.equal(r, `${registry}@isaacs/namespace-test/-/namespace-test-1.0.0.tgz`))
.then(() => f.manifest()).then(m => t.match(m, { version: '1.0.0' }))
.then(() => f.extract(me + '/namespace-test'))
.then(result => t.deepEqual(result, {
.then(result => t.same(result, {
resolved: `${registry}@isaacs/namespace-test/-/namespace-test-1.0.0.tgz`,
integrity: 'sha512-5ZYe1LgwHIaag0p9loMwsf5N/wJ4XAuHVNhSO+qulQOXWnyJVuco6IZjo+5u4ZLF/GimdHJcX+QK892ONfOCqQ==',
from: "@isaacs/namespace-test@",
Expand Down Expand Up @@ -160,7 +160,7 @@ t.test('a manifest that lacks integrity', async t => {
const mani = await f.manifest()
t.notOk(mani._integrity, 'should have no integrity')
const result = await f.extract(me + '/no-integrity')
t.deepEqual(result, {
t.same(result, {
resolved: `${registry}no-integrity/-/no-integrity-1.2.3.tgz`,
integrity: 'sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==',
from: "no-integrity@",
Expand Down

0 comments on commit 99738cd

Please sign in to comment.