Submit
Path:
~
/
/
usr
/
local
/
lib
/
node_modules
/
npm
/
test
/
tap
/
File Content:
view.js
var common = require('../common-tap.js') var test = require('tap').test var osenv = require('osenv') var path = require('path') var fs = require('fs') var rimraf = require('rimraf') var mkdirp = require('mkdirp') var tmp = osenv.tmpdir() var t1dir = path.resolve(tmp, 'view-local-no-pkg') var t2dir = path.resolve(tmp, 'view-local-notmine') var t3dir = path.resolve(tmp, 'view-local-mine') var mr = require('npm-registry-mock') var server test('setup', function (t) { mkdirp.sync(t1dir) mkdirp.sync(t2dir) mkdirp.sync(t3dir) fs.writeFileSync(t2dir + '/package.json', JSON.stringify({ author: 'Evan Lucas', name: 'test-repo-url-https', version: '0.0.1' }), 'utf8') fs.writeFileSync(t3dir + '/package.json', JSON.stringify({ author: 'Evan Lucas', name: 'biscuits', version: '0.0.1' }), 'utf8') t.pass('created fixtures') mr({ port: common.port, plugin: plugin }, function (er, s) { server = s t.end() }) }) function plugin (server) { server .get('/biscuits') .many() .reply(404, {'error': 'version not found'}) } test('npm view . in global mode', function (t) { process.chdir(t1dir) common.npm([ 'view', '.', '--registry=' + common.registry, '--global' ], { cwd: t1dir }, function (err, code, stdout, stderr) { t.ifError(err, 'view command finished successfully') t.equal(code, 1, 'exit not ok') t.similar(stderr, /Cannot use view command in global mode./m) t.end() }) }) test('npm view --global', function (t) { process.chdir(t1dir) common.npm([ 'view', '--registry=' + common.registry, '--global' ], { cwd: t1dir }, function (err, code, stdout, stderr) { t.ifError(err, 'view command finished successfully') t.equal(code, 1, 'exit not ok') t.similar(stderr, /Cannot use view command in global mode./m) t.end() }) }) test('npm view . with no package.json', function (t) { process.chdir(t1dir) common.npm([ 'view', '.', '--registry=' + common.registry ], { cwd: t1dir }, function (err, code, stdout, stderr) { t.ifError(err, 'view command finished successfully') t.equal(code, 1, 'exit not ok') t.similar(stderr, /Invalid package.json/m) t.end() }) }) test('npm view . with no published package', function (t) { process.chdir(t3dir) common.npm([ 'view', '.', '--registry=' + common.registry ], { cwd: t3dir }, function (err, code, stdout, stderr) { t.ifError(err, 'view command finished successfully') t.equal(code, 1, 'exit not ok') t.similar(stderr, /version not found/m) t.end() }) }) test('npm view .', function (t) { process.chdir(t2dir) common.npm([ 'view', '.', '--registry=' + common.registry ], { cwd: t2dir }, function (err, code, stdout) { t.ifError(err, 'view command finished successfully') t.equal(code, 0, 'exit ok') var re = new RegExp("name: 'test-repo-url-https'") t.similar(stdout, re) t.end() }) }) test('npm view . select fields', function (t) { process.chdir(t2dir) common.npm([ 'view', '.', 'main', '--registry=' + common.registry ], { cwd: t2dir }, function (err, code, stdout) { t.ifError(err, 'view command finished successfully') t.equal(code, 0, 'exit ok') t.equal(stdout.trim(), 'index.js', 'should print `index.js`') t.end() }) }) test('npm view .@<version>', function (t) { process.chdir(t2dir) common.npm([ 'view', '.@0.0.0', 'version', '--registry=' + common.registry ], { cwd: t2dir }, function (err, code, stdout) { t.ifError(err, 'view command finished successfully') t.equal(code, 0, 'exit ok') t.equal(stdout.trim(), '0.0.0', 'should print `0.0.0`') t.end() }) }) test('npm view .@<version> version --json', function (t) { process.chdir(t2dir) common.npm([ 'view', '.@0.0.0', 'version', '--json', '--registry=' + common.registry ], { cwd: t2dir }, function (err, code, stdout) { t.ifError(err, 'view command finished successfully') t.equal(code, 0, 'exit ok') t.equal(stdout.trim(), '"0.0.0"', 'should print `"0.0.0"`') t.end() }) }) test('npm view . --json author name version', function (t) { process.chdir(t2dir) common.npm([ 'view', '.', 'author', 'name', 'version', '--json', '--registry=' + common.registry ], { cwd: t2dir }, function (err, code, stdout) { var expected = JSON.stringify({ author: 'Evan Lucas <evanlucas@me.com>', name: 'test-repo-url-https', version: '0.0.1' }, null, 2) t.ifError(err, 'view command finished successfully') t.equal(code, 0, 'exit ok') t.equal(stdout.trim(), expected, 'should print ' + expected) t.end() }) }) test('npm view .@<version> --json author name version', function (t) { process.chdir(t2dir) common.npm([ 'view', '.@0.0.0', 'author', 'name', 'version', '--json', '--registry=' + common.registry ], { cwd: t2dir }, function (err, code, stdout) { var expected = JSON.stringify({ author: 'Evan Lucas <evanlucas@me.com>', name: 'test-repo-url-https', version: '0.0.0' }, null, 2) t.ifError(err, 'view command finished successfully') t.equal(code, 0, 'exit ok') t.equal(stdout.trim(), expected, 'should print ' + expected) t.end() }) }) test('npm view <package name>', function (t) { common.npm([ 'view', 'underscore', '--registry=' + common.registry ], { cwd: t2dir }, function (err, code, stdout) { t.ifError(err, 'view command finished successfully') t.equal(code, 0, 'exit ok') var re = new RegExp("name: 'underscore'") t.similar(stdout, re, 'should have name `underscore`') t.end() }) }) test('npm view <package name> --global', function (t) { common.npm([ 'view', 'underscore', '--global', '--registry=' + common.registry ], { cwd: t2dir }, function (err, code, stdout) { t.ifError(err, 'view command finished successfully') t.equal(code, 0, 'exit ok') var re = new RegExp("name: 'underscore'") t.similar(stdout, re, 'should have name `underscore`') t.end() }) }) test('npm view <package name>@<semver range> versions', function (t) { common.npm([ 'view', 'underscore@^1.5.0', 'versions', '--registry=' + common.registry ], { cwd: t2dir }, function (err, code, stdout) { t.ifError(err, 'view command finished successfully') t.equal(code, 0, 'exit ok') var re = new RegExp('1.5.0') t.similar(stdout, re, 'should have version `1.5.0`') t.end() }) }) test('npm view <package name>@<semver range> version --json', function (t) { common.npm([ 'view', 'underscore@~1.5.0', 'version', '--json', '--registry=' + common.registry ], { cwd: t2dir }, function (err, code, stdout) { t.ifError(err, 'view command finished successfully') t.equal(code, 0, 'exit ok') t.equal(stdout.trim(), JSON.stringify([ '1.5.0', '1.5.1' ], null, 2), 'should have three versions') t.end() }) }) test('npm view <package name> --json', function (t) { t.plan(3) common.npm([ 'view', 'underscore', '--json', '--registry=' + common.registry ], { cwd: t2dir }, function (err, code, stdout) { t.ifError(err, 'view command finished successfully') t.equal(code, 0, 'exit ok') try { var out = JSON.parse(stdout.trim()) t.similar(out, { maintainers: ['jashkenas <jashkenas@gmail.com>'] }, 'should have the same maintainer') } catch (er) { t.fail('Unable to parse JSON') } }) }) test('npm view <package name>@<invalid version>', function (t) { common.npm([ 'view', 'underscore@12345', '--registry=' + common.registry ], { cwd: t2dir }, function (err, code, stdout) { t.ifError(err, 'view command finished successfully') t.equal(code, 0, 'exit ok') t.equal(stdout.trim(), '', 'should return empty') t.end() }) }) test('npm view <package name>@<invalid version> --json', function (t) { common.npm([ 'view', 'underscore@12345', '--json', '--registry=' + common.registry ], { cwd: t2dir }, function (err, code, stdout) { t.ifError(err, 'view command finished successfully') t.equal(code, 0, 'exit ok') t.equal(stdout.trim(), '', 'should return empty') t.end() }) }) test('npm view <package name> <field>', function (t) { common.npm([ 'view', 'underscore', 'homepage', '--registry=' + common.registry ], { cwd: t2dir }, function (err, code, stdout) { t.ifError(err, 'view command finished successfully') t.equal(code, 0, 'exit ok') t.equal(stdout.trim(), 'http://underscorejs.org', 'homepage should equal `http://underscorejs.org`') t.end() }) }) test('npm view with invalid package name', function (t) { var invalidName = 'InvalidPackage' server.get('/' + invalidName).reply('404', {'error': 'not found'}) common.npm([ 'view', invalidName, '--registry=' + common.registry ], {}, function (err, code, stdout, stderr) { t.ifError(err, 'view command finished successfully') t.equal(code, 1, 'exit not ok') t.similar(stderr, new RegExp('is not in the npm registry'), 'Package should NOT be found') t.dissimilar(stderr, new RegExp('use the name yourself!'), 'Suggestion should not be there') t.similar(stderr, new RegExp('name can no longer contain capital letters'), 'Suggestion about Capital letter should be there') t.end() }) }) test('npm view with valid but non existent package name', function (t) { server.get('/valid-but-non-existent-package').reply(404, {'error': 'not found'}) common.npm([ 'view', 'valid-but-non-existent-package', '--registry=' + common.registry ], {}, function (err, code, stdout, stderr) { t.ifError(err, 'view command finished successfully') t.equal(code, 1, 'exit not ok') t.similar(stderr, new RegExp("'valid-but-non-existent-package' is not in the npm registry\."), 'Package should NOT be found') t.similar(stderr, new RegExp('use the name yourself!'), 'Suggestion should be there') t.end() }) }) test('cleanup', function (t) { process.chdir(osenv.tmpdir()) rimraf.sync(t1dir) rimraf.sync(t2dir) rimraf.sync(t3dir) t.pass('cleaned up') server.close() t.end() })
Submit
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