Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Use silly-high version number for linked packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Nov 14, 2010
1 parent 351fc99 commit edd875a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
12 changes: 12 additions & 0 deletions doc/link.md
Expand Up @@ -11,3 +11,15 @@ This will link a source folder into npm's registry using a symlink, and then
build it according to the package.json file in that folder's root. This is
handy for installing your own stuff, so that you can work on it and test it
iteratively without having to continually rebuild.

## Linked Package Version

When linking a package folder, npm doesn't use the version in the
package.json file. Instead, it creates a "fake" version number of:

"9999.0.0-LINK-" + hash(folder)

This way, linking the same folder will always result in the same version
number, even if you bump the version in the package.json file. The
extremely high major version ensures that it will always be considered
the "highest" version, since it is a development bleeding-edge thing.
2 changes: 1 addition & 1 deletion lib/link.js
Expand Up @@ -45,7 +45,7 @@ function link (args, cb) {
function readAndLink (jsonFile, folder, cb) {
readJson
( jsonFile
, { "tag" : "-1-LINK-"+(
, { "tag" : "9999.0.0-LINK-"+(
crypto.createHash("sha1").update(folder).digest("hex").substr(0,8)
)}
, doLink(folder, cb)
Expand Down
10 changes: 1 addition & 9 deletions lib/utils/read-json.js
Expand Up @@ -85,15 +85,7 @@ function processObject (opts, cb) { return function (er, json) {
throw e
}
var tag = opts.tag
if (tag && tag.indexOf(json.version) === 0) {
tag = tag.substr(json.version.length)
}
if (tag && tag.indexOf("-1-LINK") !== -1) {
tag = tag.substr(tag.indexOf("-1-LINK"))
}
if (tag && semver.valid(json.version + tag)) {
json.version += tag
}
if (tag) json.version = tag//+"-"+json.version

// FIXME: uncomment in 0.3.0, once it's not likely that people will
// have a bunch of main.js files kicking around any more, and remove
Expand Down

0 comments on commit edd875a

Please sign in to comment.