Shea Levy avatar Shea Levy committed 5a3daef

Handle empty-string specs properly

Comments (0)

Files changed (2)

src/npm2nix.coffee

     patchLatest = 'false'
     for nm, spc of pkg.dependencies or {}
       spc = spc.version if spc instanceof Object
-      if spc is 'latest'
+      if spc is 'latest' or spec is ''
         spc = '*'
       stream.write "\n      { name = \"#{escapeNixString nm}\"; spec = \"#{escapeNixString spc}\"; }"
     stream.write "\n    ];"
       process.exit 8
 
     addPackage = (name, spec) ->
-      spec = '*' if spec is 'latest' #ugh
+      spec = '*' if spec is 'latest' or spec is '' #ugh
       fullNames[name] ?= {}
       fullNames[name][spec] = true
       fetcher.fetch name, spec, registry

src/package-fetcher.coffee

       dep1 = dep1.version
     if dep2 instanceof Object
       dep2 = dep2.version
-    if dep1 is 'latest'
+    if dep1 is 'latest' or dep1 is ''
       dep1 = '*'
-    if dep2 is 'latest'
+    if dep2 is 'latest' or dep2 is ''
       dep2 = '*'
     if semver.validRange(dep1, true) and semver.validRange(dep2, true)
       merged = new semver.Range dep1, true
       if dep is 'latest'
         pkg.patchLatest = true
         dep = '*'
+      if dep is ''
+        dep = '*'
       @fetch nm, dep, thisRegistry
     for nm, dep of pkg.dependencies or {}
       handleDep nm, dep
         if dep is 'latest'
           dep = '*'
           pkg.patchLatest = true
+        if dep is ''
+          dep = '*'
         if nm of pkg.dependencies
           merged = tryMergeDeps dep, pkg.dependencies[nm]
           if merged?
     for nm, dep of pkg.dependencies or {}
       if dep instanceof Object
         dep = dep.version
-      if dep is 'latest'
+      if dep is 'latest' or dep is ''
         dep = '*'
       @_getPeerDependencies nm, dep, handlePeerDependencies
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.