Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/npmconf/lib/load-cafile.js')
-rw-r--r--node_modules/npmconf/lib/load-cafile.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/node_modules/npmconf/lib/load-cafile.js b/node_modules/npmconf/lib/load-cafile.js
new file mode 100644
index 000000000..402058bdd
--- /dev/null
+++ b/node_modules/npmconf/lib/load-cafile.js
@@ -0,0 +1,28 @@
+module.exports = loadCAFile
+
+var fs = require('fs')
+
+function loadCAFile(cafilePath, cb) {
+ fs.readFile(cafilePath, 'utf8', afterCARead.bind(this))
+
+ function afterCARead(er, cadata) {
+ if (er)
+ return cb(er)
+
+ var delim = '-----END CERTIFICATE-----'
+ var output
+
+ output = cadata
+ .split(delim)
+ .filter(function(xs) {
+ return !!xs.trim()
+ })
+ .map(function(xs) {
+ return xs.trimLeft() + delim
+ })
+
+ this.set('ca', output)
+ cb(null)
+ }
+
+}