Description : Creating and Adding new layer for tizen micro profile base.
[scm/bb/meta-tizen.git] / meta-tizen-micro / recipes-devtools / nodejs / nodejs / no-registry.patch
1 Bugfix for --no-registry in nodejs-v0.12.2
2
3 diff -u -r node-v0.12.2_def/deps/npm/lib/cache/caching-client.js node-v0.12.2/deps/npm/lib/cache/caching-client.js
4 --- node-v0.12.2_def/deps/npm/lib/cache/caching-client.js       2015-04-01 01:13:01.000000000 +0300
5 +++ node-v0.12.2/deps/npm/lib/cache/caching-client.js   2015-05-18 00:47:10.738599686 +0300
6 @@ -67,6 +67,22 @@
7    var cacheBase = cacheFile(npm.config.get("cache"))(uri)
8    var cachePath = path.join(cacheBase, ".cache.json")
9  
10 +  if (parsed.host === "noregistry") (function() {
11 +    var stat = null
12 +    var file = npm.config.get("cache") + parsed.pathname + "/.cache.json"
13 +    try {
14 +      stat = fs.statSync(cachePath)
15 +    } catch (ex) {}
16 +    if (!stat) try {
17 +      stat = fs.statSync(file) 
18 +      cachePath = file
19 +    } catch (ex) {
20 +      stat = "Registry not defined and registry files not found: \"" +
21 +             cachePath + "\", \"" + file + "\"."
22 +      throw new Error(stat)
23 +    }
24 +  })()
25 +
26    // If the GET is part of a write operation (PUT or DELETE), then
27    // skip past the cache entirely, but still save the results.
28    if (uri.match(/\?write=true$/)) {
29 @@ -83,12 +99,17 @@
30          }
31          catch (ex) {
32            data = null
33 +          if (parsed.host === "noregistry")
34 +            throw new Error("File \"" + cachePath+"\"" + " corrupted.")
35          }
36  
37          params.stat = stat
38          params.data = data
39  
40 -        get_.call(client, uri, cachePath, params, cb)
41 +        if (parsed.host === "noregistry")
42 +          cb(null, data, JSON.stringify(data), { statusCode : 304 })
43 +        else
44 +          get_.call(client, uri, cachePath, params, cb)
45        })
46      }
47      else {
48 diff -u -r node-v0.12.2_def/deps/npm/lib/utils/map-to-registry.js node-v0.12.2/deps/npm/lib/utils/map-to-registry.js
49 --- node-v0.12.2_def/deps/npm/lib/utils/map-to-registry.js      2015-04-01 01:13:01.000000000 +0300
50 +++ node-v0.12.2/deps/npm/lib/utils/map-to-registry.js  2015-05-18 01:15:10.030569613 +0300
51 @@ -45,6 +45,8 @@
52  
53    log.silly("mapToRegistry", "registry", registry)
54  
55 +  if (!registry) return cb(null, "http://noregistry/" + name, {})
56 +
57    var auth = config.getCredentialsByURI(registry)
58  
59    // normalize registry URL so resolution doesn't drop a piece of registry URL