From d4a44f893cc78f9f395e6d7856ad8ef2124b0b02 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 15 Dec 2015 03:51:41 -0800 Subject: [PATCH] add default handlers --- lib/default-handlers.js | 5 +++++ lib/default-remove-challenge.js | 10 ++++++++++ lib/default-set-challenge.js | 21 +++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 lib/default-handlers.js create mode 100644 lib/default-remove-challenge.js create mode 100644 lib/default-set-challenge.js diff --git a/lib/default-handlers.js b/lib/default-handlers.js new file mode 100644 index 0000000..88ed6b4 --- /dev/null +++ b/lib/default-handlers.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports.agreeToTerms = function (args, agree) { + agree(args.agreeTos || args.agree); +}; diff --git a/lib/default-remove-challenge.js b/lib/default-remove-challenge.js new file mode 100644 index 0000000..1aedfdd --- /dev/null +++ b/lib/default-remove-challenge.js @@ -0,0 +1,10 @@ +'use strict'; + +var path = require('path'); +var fs = require('fs'); + +module.exports = function (args, key, done) { + //var hostname = args.domains[0]; + + fs.unlinkSync(path.join(args.webroot, key), done); +}; diff --git a/lib/default-set-challenge.js b/lib/default-set-challenge.js new file mode 100644 index 0000000..4aec345 --- /dev/null +++ b/lib/default-set-challenge.js @@ -0,0 +1,21 @@ +'use strict'; + +var fs = require('fs'); +var path = require('path'); + +module.exports = function (args, challengePath, keyAuthorization, done) { + //var hostname = args.domains[0]; + var mkdirp = require('mkdirp'); + + // TODO should be args.webrootPath + mkdirp(path.join(args.webrootPath, challengePath), function (err) { + if (err) { + done(err); + return; + } + + fs.writeFile(path.join(args.webrootPath, challengePath), keyAuthorization, 'utf8', function (err) { + done(err); + }); + }); +};