Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

tilde mode with -t

  • Loading branch information...
commit aab1900b414c5a875471b7befff3b711a5f67d82 1 parent 5cc22d4
James Halliday substack authored

Showing 2 changed files with 20 additions and 1 deletion. Show diff stats Hide diff stats

  1. +14 0 README.md
  2. +6 1 lib/npmlv.js
14 README.md
Source Rendered
@@ -27,6 +27,20 @@ Prints:
27 27 }
28 28 ```
29 29
  30 +To print dependencies for floating patch versions:
  31 +
  32 + npmlv -t
  33 +
  34 +Prints:
  35 +
  36 +```js
  37 +{
  38 + "async-mini": "~0.1.0",
  39 + "laeh2": "~0.2.0",
  40 + "mongodb": "~0.9.7",
  41 + "underscore": "~1.1.7"
  42 +}
  43 +```
30 44 To print dependencies on exact and higher versions (optimistic):
31 45
32 46 npmlv -n
7 lib/npmlv.js
@@ -7,6 +7,7 @@ program
7 7 .usage('\List module versions in your project in format easy to copy and paste to your package.json.\nUsage: $0')
8 8 .option('-a, --any', 'User any version specifier "*", instead of exact version.')
9 9 .option('-n, --newer', 'User equal or newer version specifier ">=", instead of exact version.')
  10 + .option('-t, --tilde', 'Use tilde "~" for floating patch versions.')
10 11 .parse(process.argv);
11 12
12 13 var res = {};
@@ -27,7 +28,11 @@ for(var i = 0; i < dirs.length; i++) {
27 28 try {
28 29 var config = JSON.parse(fs.readFileSync(cfg));
29 30 if(config.version)
30   - res[module] = program.any ? "*" : ((program.newer ? '>=' : '') + config.version);
  31 + res[module] = (program.any ? "*" :
  32 + program.newer ? ">=" :
  33 + program.tilde ? "~" :
  34 + ""
  35 + ) + config.version;
31 36 else
32 37 console.log('No version information for module ' + module);
33 38 }

0 comments on commit aab1900

Please sign in to comment.
Something went wrong with that request. Please try again.