Submit
Path:
~
/
/
usr
/
local
/
lib
/
node_modules
/
npm
/
test
/
tap
/
File Content:
retry-on-stale-cache.js
var path = require('path') var mr = require('npm-registry-mock') var test = require('tap').test var common = require('../common-tap') var extend = Object.assign || require('util')._extend var Tacks = require('tacks') var Dir = Tacks.Dir var File = Tacks.File var workdir = path.join(__dirname, path.basename(__filename, '.js')) var cachedir = path.join(workdir, 'cache') var modulesdir = path.join(workdir, 'modules') var oldModule = path.join(modulesdir, 'good-night-0.1.0.tgz') var newModule = path.join(modulesdir, 'good-night-1.0.0.tgz') var config = [ '--cache', cachedir, '--prefix', workdir, '--registry', common.registry ] var fixture = new Tacks(Dir({ 'cache': Dir(), 'modules': Dir({ 'good-night-0.1.0.tgz': File(new Buffer( '1f8b0800000000000003ed934f4bc43010c57beea7187a59056dd36eff80' + 'de85050541c1f3d8c634da4e4a925a8af8dd6db7bb8ba0e0c15559e9eff2' + '206f929909bc06f327143c6826f51f8d2267cf30c6d2388641c32c61ef75' + '4d9426e084519a25491645cbcc61e192c5d1e0ef7b90cf688d453d8cf2dd' + '77a65d60a707c28b0b031e61cdbd33f08452c52949515aef64729eb93652' + 'd168323ff4d9f6bce026d7b2b11bafef11b1eb3a221a2aa6126c6da9f4e8' + '5e691f6e908a1a697b5ff346196995eec7023399c1c7fe95cc3999f57077' + 'b717d7979efbeafef5a7fd2336b90f6a943484ff477a7c917f96c5bbfc87' + '493ae63f627138e7ff37c815195571bf52e268b1820e0d0825498055d069' + '6939d8521ab86f2dace0815715a0a9386f16c7e7730c676666660e9837c0' + 'f6795d000c0000', 'hex' )), 'good-night-1.0.0.tgz': File(new Buffer( '1f8b0800000000000003ed954d6bc24010863dfb2bb6b9a8503793b849a0' + 'eda5979efa052d484184252e495a331b76d78a94fef76e8cf683163cd42a' + '957d2e03796777268187543c7de299f0aba6d2472db1b5650020668cd81a' + '24117cae4bc23822ad208c93284a1208c216040318c436dff6223f31d386' + '2bbbca6fef69de85bcd77fc24b9b583ce4a5f04e88974939e96391e5c63b' + '6e9267a17421b10e030a14d6cf2742a7aaa8cc2a5b2c38e7f3f91c116d47' + 'd3c2672697aa4eaf1425771c2725c7f579252aa90b23d5a26ed04de87f9f' + '3f2d52817ab9dcf0fee2f6d26bbfb6f7fdd10e8895f77ec90bb4f2ffc98c' + '0dfe439c7cf81fc4b5ff213070feef8254a2965341a732eb76b4cef39c12' + 'e456eb52d82a29198dc637639f9c751fce8796eba35ea777ea0c3c14d6fe' + '532314f62ba9ccf6676cf21fbefcff59ed3f4b22e7ff2e60110bc37d2fe1' + '70381c8e9df306642df14500100000', 'hex' )) }) })) var server // In this test we mock a situation where the user has a package in his cache, // a newer version of the package is published, and the user tried to install // said new version while requestion that the cache be used. // npm should see that it doesn't have the package in its cache and hit the // registry. var onlyOldMetadata = { 'name': 'good-night', 'dist-tags': { 'latest': '0.1.0' }, 'versions': { '0.1.0': { 'name': 'good-night', 'version': '0.1.0', 'dist': { 'shasum': '2a746d49dd074ba0ec2d6ff13babd40c658d89eb', 'tarball': 'http://localhost:' + common.port + '/good-night/-/good-night-0.1.0.tgz' } } } } var oldAndNewMetadata = extend({}, onlyOldMetadata) oldAndNewMetadata['dist-tags'] = { latest: '1.0.0' } oldAndNewMetadata.versions = extend({ '1.0.0': { 'name': 'good-night', 'version': '1.0.0', 'dist': { 'shasum': 'f377bf002a0a8fc4085d347a160a790b76896bc3', 'tarball': 'http://localhost:' + common.port + '/good-night/-/good-night-1.0.0.tgz' } } }, oldAndNewMetadata.versions) function setup () { cleanup() fixture.create(workdir) } function cleanup () { fixture.remove(workdir) } test('setup', function (t) { setup() t.end() }) test('setup initial server', function (t) { mr({ port: common.port, throwOnUnmatched: true }, function (err, s) { t.ifError(err, 'registry mocked successfully') server = s server.get('/good-night') .many({ min: 1, max: 1 }) .reply(200, onlyOldMetadata) server.get('/good-night/-/good-night-0.1.0.tgz') .many({ min: 1, max: 1 }) .replyWithFile(200, oldModule) t.end() }) }) test('install initial version', function (t) { common.npm(config.concat([ 'install', 'good-night' ]), {stdio: 'inherit'}, function (err, code) { if (err) throw err t.is(code, 0, 'initial install succeeded') server.done() t.end() }) }) test('cleanup initial server', function (t) { server.close() t.end() }) test('setup new server', function (t) { mr({ port: common.port, throwOnUnmatched: true }, function (err, s) { t.ifError(err, 'registry mocked successfully') server = s server.get('/good-night') .many({ min: 1, max: 1 }) .reply(200, oldAndNewMetadata) server.get('/good-night/-/good-night-1.0.0.tgz') .many({ min: 1, max: 1 }) .replyWithFile(200, newModule) t.end() }) }) test('install new version', function (t) { common.npm(config.concat([ '--prefer-offline', 'install', 'good-night@1.0.0' ]), {}, function (err, code, stdout, stderr) { if (err) throw err t.equal(stderr, '', 'no error output') t.is(code, 0, 'install succeeded') t.end() }) }) test('install does not hit server again', function (t) { // The mock server route definitions ensure we don't hit the server again common.npm(config.concat([ '--prefer-offline', '--parseable', 'install', 'good-night' ]), {stdio: [0, 'pipe', 2]}, function (err, code, stdout) { if (err) throw err t.is(code, 0, 'install succeeded') t.match(stdout, /^update\tgood-night\t1.0.0\t/, 'installed latest version') server.done() t.end() }) }) test('cleanup', function (t) { server.close() cleanup() t.end() })
Edit
Rename
Chmod
Delete
FILE
FOLDER
Name
Size
Permission
Action
00-check-mock-dep.js
500 bytes
0644
00-config-setup.js
2812 bytes
0644
00-verify-bundle-deps.js
377 bytes
0644
00-verify-ls-ok.js
628 bytes
0644
00-verify-no-scoped.js
1118 bytes
0644
404-parent.js
1634 bytes
0644
404-private-registry-scoped.js
1315 bytes
0644
404-private-registry.js
1243 bytes
0644
access.js
12209 bytes
0644
add-named-update-protocol-port.js
2526 bytes
0644
add-remote-git-file.js
2405 bytes
0644
add-remote-git-shrinkwrap.js
3468 bytes
0644
add-remote-git-submodule.js
3632 bytes
0644
add-remote-git.js
2486 bytes
0644
adduser-always-auth.js
7225 bytes
0644
adduser-legacy-auth.js
2673 bytes
0644
adduser-oauth.js
2419 bytes
0644
adduser-saml.js
2414 bytes
0644
all-package-metadata-cache-stream-unit.js
3766 bytes
0644
all-package-metadata-entry-stream-unit.js
5588 bytes
0644
all-package-metadata-update-stream-unit.js
4725 bytes
0644
all-package-metadata-write-stream-unit.js
3614 bytes
0644
all-package-metadata.js
5742 bytes
0644
anon-cli-metrics.js
4079 bytes
0644
bearer-token-check.js
3133 bytes
0644
bin.js
648 bytes
0644
bitbucket-https-url-with-creds-package.js
1944 bytes
0644
bitbucket-https-url-with-creds.js
1873 bytes
0644
bitbucket-shortcut-package.js
1938 bytes
0644
bitbucket-shortcut.js
1888 bytes
0644
bugs.js
5011 bytes
0644
build-already-built.js
2055 bytes
0644
builtin-config.js
4029 bytes
0644
bundled-dependencies-no-pkgjson.js
1406 bytes
0644
bundled-dependencies-nonarray.js
1752 bytes
0644
bundled-dependencies.js
2678 bytes
0644
bundled-no-add-to-move.js
1384 bytes
0644
bundled-transitive-deps.js
2343 bytes
0644
cache-add-unpublished.js
798 bytes
0644
cache-shasum-fork.js
2771 bytes
0644
check-cpu-reqs.js
1584 bytes
0644
check-engine-reqs.js
1665 bytes
0644
check-install-self.js
1682 bytes
0644
check-os-reqs.js
1579 bytes
0644
check-permissions.js
2445 bytes
0644
ci-header.js
3241 bytes
0644
circular-dep.js
2360 bytes
0644
config-basic.js
2181 bytes
0644
config-builtin.js
1398 bytes
0644
config-certfile.js
541 bytes
0644
config-credentials.js
8520 bytes
0644
config-edit.js
1666 bytes
0644
config-list.js
1844 bytes
0644
config-malformed.js
379 bytes
0644
config-meta.js
4076 bytes
0644
config-new-cafile.js
1224 bytes
0644
config-private.js
1855 bytes
0644
config-project.js
1416 bytes
0644
config-save.js
2181 bytes
0644
correct-mkdir.js
4543 bytes
0644
cruft-test.js
942 bytes
0644
debug-logs.js
2977 bytes
0644
dedupe-scoped.js
3685 bytes
0644
dedupe.js
2581 bytes
0644
deprecate.js
4039 bytes
0644
dist-tag.js
4754 bytes
0644
do-not-remove-other-bins.js
3031 bytes
0644
doctor.js
2984 bytes
0644
extraneous-dep-cycle-ls-ok.js
1514 bytes
0644
false-name.js
2044 bytes
0644
fetch-package-metadata.js
1581 bytes
0644
files-and-ignores.js
20041 bytes
0644
full-warning-messages.js
2847 bytes
0644
gently-rm-cmdshims.js
5175 bytes
0644
gently-rm-linked-module.js
3171 bytes
0644
gently-rm-overeager.js
1464 bytes
0644
gently-rm-symlinked-global-dir.js
2989 bytes
0644
get.js
2323 bytes
0644
gist-short-shortcut-package.js
2042 bytes
0644
gist-short-shortcut.js
2000 bytes
0644
gist-shortcut-package.js
2028 bytes
0644
gist-shortcut.js
1960 bytes
0644
git-dependency-install-link.js
4239 bytes
0644
git-npmignore.js
4886 bytes
0644
git-prepare.js
4003 bytes
0644
github-shortcut-package.js
2002 bytes
0644
github-shortcut.js
2006 bytes
0644
gitlab-shortcut-package.js
1928 bytes
0644
gitlab-shortcut.js
1897 bytes
0644
global-prefix-set-in-userconfig.js
843 bytes
0644
graceful-restart.js
2663 bytes
0644
help.js
625 bytes
0644
ignore-install-link.js
1959 bytes
0644
ignore-scripts.js
3354 bytes
0644
init-interrupt.js
1382 bytes
0644
install-actions.js
2498 bytes
0644
install-at-locally.js
1760 bytes
0644
install-bad-dep-format.js
1269 bytes
0644
install-bad-man.js
1738 bytes
0644
install-bin-null.js
1834 bytes
0644
install-cli-only-development.js
2839 bytes
0644
install-cli-only-production.js
2068 bytes
0644
install-cli-only-shrinkwrap.js
3239 bytes
0644
install-cli-production-nosave.js
1396 bytes
0644
install-cli-production.js
2050 bytes
0644
install-cli-unicode.js
1484 bytes
0644
install-duplicate-deps-warning.js
1563 bytes
0644
install-from-local.js
2414 bytes
0644
install-into-likenamed-folder.js
998 bytes
0644
install-link-scripts.js
2742 bytes
0644
install-local-dep-cycle.js
1448 bytes
0644
install-man.js
1593 bytes
0644
install-noargs-dev.js
2312 bytes
0644
install-order.js
1130 bytes
0644
install-package-json-order.js
1751 bytes
0644
install-package-lock-only.js
2197 bytes
0644
install-parse-error.js
959 bytes
0644
install-property-conflicts.js
1546 bytes
0644
install-report-just-installed.js
1572 bytes
0644
install-save-exact.js
2561 bytes
0644
install-save-local.js
5428 bytes
0644
install-save-prefix.js
4275 bytes
0644
install-scoped-already-installed.js
3710 bytes
0644
install-scoped-link.js
2040 bytes
0644
install-scoped-with-bundled-dependency.js
1798 bytes
0644
install-scoped-with-peer-dependency.js
1419 bytes
0644
install-shrinkwrapped-git.js
4407 bytes
0644
install-windows-newlines.js
2185 bytes
0644
install-with-dev-dep-duplicate.js
1894 bytes
0644
invalid-cmd-exit-code.js
1057 bytes
0644
invalid-dep-version-filtering.js
3341 bytes
0644
is-fs-access-available.js
1926 bytes
0644
is-registry.js
1220 bytes
0644
it.js
2065 bytes
0644
legacy-ignore-nested-nm.js
1764 bytes
0644
legacy-missing-bindir.js
1814 bytes
0644
legacy-no-auth-leak.js
1962 bytes
0644
legacy-platform-all.js
1529 bytes
0644
legacy-platform.js
1409 bytes
0644
legacy-private.js
1286 bytes
0644
legacy-test-package.js
1772 bytes
0644
lifecycle-INIT_CWD.js
1118 bytes
0644
lifecycle-order.js
1694 bytes
0644
link.js
5925 bytes
0644
local-args-relative-to-cwd.js
1282 bytes
0644
locker.js
2273 bytes
0644
lockfile-http-deps.js
2197 bytes
0644
logout-scoped.js
1418 bytes
0644
logout.js
1353 bytes
0644
ls-depth-cli.js
5338 bytes
0644
ls-depth-unmet.js
4259 bytes
0644
ls-env.js
3302 bytes
0644
ls-l-depth-0.js
2695 bytes
0644
ls-no-results.js
368 bytes
0644
ls-production-and-dev.js
4125 bytes
0644
ls-top-errors.js
1400 bytes
0644
ls.js
4369 bytes
0644
map-to-registry.js
5024 bytes
0644
nerf-dart.js
1220 bytes
0644
nested-extraneous.js
1213 bytes
0644
no-global-warns.js
1889 bytes
0644
no-scan-full-global-dir.js
3008 bytes
0644
noargs-install-config-save.js
2011 bytes
0644
node-modules-path-munge.js
986 bytes
0644
normalize-package-explode.js
523 bytes
0644
npm-api-not-loaded-error.js
1028 bytes
0644
onload.js
1297 bytes
0644
optional-metadep-rollback-collision.js
4497 bytes
0644
outdated-bad-read-tree.js
489 bytes
0644
outdated-color.js
1600 bytes
0644
outdated-depth.js
1526 bytes
0644
outdated-git.js
1623 bytes
0644
outdated-json.js
2140 bytes
0644
outdated-long.js
2069 bytes
0644
outdated.js
2641 bytes
0644
override-bundled.js
6716 bytes
0644
owner.js
4219 bytes
0644
pack-scoped.js
1707 bytes
0644
peer-deps.js
1482 bytes
0644
pick-manifest-from-registry-metadata.js
4792 bytes
0644
ping.js
1355 bytes
0644
prepare.js
1834 bytes
0644
prepublish-only.js
3091 bytes
0644
prepublish.js
2734 bytes
0644
process-logger.js
543 bytes
0644
progress-config.js
2413 bytes
0644
prune-dev-dep-cycle.js
1803 bytes
0644
prune-dev-dep-with-bins.js
2664 bytes
0644
prune-with-dev-dep-duplicate.js
2464 bytes
0644
prune-with-only-dev-deps.js
2751 bytes
0644
prune.js
2963 bytes
0644
publish-access-scoped.js
1760 bytes
0644
publish-access-unscoped-restricted-fails.js
975 bytes
0644
publish-access-unscoped.js
1761 bytes
0644
publish-config.js
2009 bytes
0644
publish-invalid-semver-tag.js
1729 bytes
0644
publish-scoped.js
2177 bytes
0644
pwd-prefix.js
985 bytes
0644
referer.js
668 bytes
0644
repo.js
4172 bytes
0644
retry-on-stale-cache.js
5728 bytes
0644
run-script-filter-private.js
1130 bytes
0644
run-script.js
10891 bytes
0644
scope-header.js
3975 bytes
0644
scripts-whitespace-windows.js
2454 bytes
0644
search.all-package-search.js
4675 bytes
0644
search.esearch.js
4483 bytes
0644
search.js
5394 bytes
0644
semver-doc.js
426 bytes
0644
shared-linked.js
3638 bytes
0644
shrinkwrap-_auth.js
3177 bytes
0644
shrinkwrap-default-dev.js
2126 bytes
0644
shrinkwrap-dev-dependency.js
2155 bytes
0644
shrinkwrap-empty-deps.js
1631 bytes
0644
shrinkwrap-extra-metadata.js
1845 bytes
0644
shrinkwrap-global-auth.js
2895 bytes
0644
shrinkwrap-lifecycle-cwd.js
2231 bytes
0644
shrinkwrap-lifecycle.js
1445 bytes
0644
shrinkwrap-local-dependency.js
3103 bytes
0644
shrinkwrap-nested.js
3941 bytes
0644
shrinkwrap-optional-dependency.js
2222 bytes
0644
shrinkwrap-optional-platform.js
2366 bytes
0644
shrinkwrap-optional-property.js
2223 bytes
0644
shrinkwrap-prod-dependency-also.js
2698 bytes
0644
shrinkwrap-prod-dependency.js
2056 bytes
0644
shrinkwrap-save-dev-with-existing-deps.js
2929 bytes
0644
shrinkwrap-save-with-existing-dev-deps.js
2260 bytes
0644
shrinkwrap-scoped-auth.js
2949 bytes
0644
shrinkwrap-shared-dev-dependency.js
2056 bytes
0644
shrinkwrap-version-match.js
2899 bytes
0644
sorted-package-json.js
2222 bytes
0644
spawn-enoent-help.js
822 bytes
0644
spawn-enoent.js
869 bytes
0644
spec-local-specifiers.js
23353 bytes
0644
splat-with-only-prerelease-to-latest.js
2804 bytes
0644
startstop.js
1591 bytes
0644
symlink-cycle.js
1297 bytes
0644
tag-version-prefix.js
2458 bytes
0644
tagged-version-matching.js
5302 bytes
0644
team.js
3497 bytes
0644
test-run-ls.js
918 bytes
0644
tree-style.js
3569 bytes
0644
umask-lifecycle.js
1497 bytes
0644
uninstall-in-reverse.js
949 bytes
0644
uninstall-link-clean.js
2561 bytes
0644
uninstall-package.js
1837 bytes
0644
uninstall-save.js
2080 bytes
0644
unit-child-path.js
453 bytes
0644
unit-deps-earliestInstallable.js
2475 bytes
0644
unit-deps-removeObsoleteDep.js
1074 bytes
0644
unit-deps-replaceModule.js
2658 bytes
0644
unit-module-name.js
1721 bytes
0644
unit-package-id.js
960 bytes
0644
unpack-foreign-tarball.js
2217 bytes
0644
unpublish-config.js
1930 bytes
0644
unsupported.js
1215 bytes
0644
update-examples.js
5204 bytes
0644
update-path.js
881 bytes
0644
upgrade-lifecycles.js
1883 bytes
0644
url-dependencies.js
2364 bytes
0644
verify-no-lifecycle-on-repo.js
1588 bytes
0644
version-allow-same-version.js
1999 bytes
0644
version-commit-hooks-default.js
454 bytes
0644
version-commit-hooks.js
1888 bytes
0644
version-from-git.js
5988 bytes
0644
version-git-not-clean.js
2831 bytes
0644
version-lifecycle.js
5800 bytes
0644
version-message-config.js
1942 bytes
0644
version-no-git.js
1474 bytes
0644
version-no-package.js
1112 bytes
0644
version-no-tags.js
2151 bytes
0644
version-sub-directory-shrinkwrap.js
2219 bytes
0644
version-sub-directory.js
1794 bytes
0644
version-update-shrinkwrap.js
3908 bytes
0644
view.js
10410 bytes
0644
zz-cleanup.js
184 bytes
0644
N4ST4R_ID | Naxtarrr