From 9d92c2f999e9affa9470261e1f9c6dfbd2cef14b Mon Sep 17 00:00:00 2001 From: Michael Krotscheck Date: Tue, 5 Apr 2016 15:53:20 -0700 Subject: [PATCH] Added noop handler for all current registry-static hooks This patch adds no-op hooks to the module, as placeholders to indicate possible extension points. Future patches will add functionality. --- index.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/index.js b/index.js index e69de29..e959bcb 100644 --- a/index.js +++ b/index.js @@ -0,0 +1,66 @@ +(function() { + 'use strict'; + + /** + * No-op hook, executes with no modifications to the current event. + * + * @param {{}} data The currently modified data. + * @param {Function} cb Asynchronous callback with the signature cb(error, shouldSave); + * @returns {void} + */ + function noop (data, cb) { + cb(null, true); + } + + module.exports = { + /** + * Called before any data is written, at the beginning of processing a change. If the callback + * is called with an error or false, no more processing will be done for this change, and no + * files will be written. + */ + beforeAll: noop, + + /** + * Called after all the data is written, at the end of processing a change. If there is no + * error, the callback parameters are ignored. + */ + afterAll: noop, + + /** + * Called before writing an update to the top-level index.json. + */ + globalIndexJson: noop, + + /** + * Called before writing a package's main index.json. + */ + indexJson: noop, + + /** + * Called before writing the index.json for a particular package version. + */ + versionJson: noop, + + /** + * Called before downloading/verifying/writing a package tarball. + */ + tarball: noop, + + /** + * Called after downloading/verifying/writing a package tarball. If there is no error, the + * callback parameters are ignored. + */ + afterTarball: noop, + + /** + * Called before doing anything else at start time. + */ + startup: noop, + + /** + * Called in order to check the sha1sum of a tarball. Calling back with true implies the shasum + * passed. Default is in lib/defaultShasumCheck.js. + */ + shasumCheck: noop + }; +})();