index.js
function saveFile(backend, file, data, cb) {
  cb = typeof(cb) === 'function' ? cb : function () {};

  getBackendConfig(backend, function (err, config) {
    var datadir = config[':datadir'];
    file = path.join(datadir, file);

    fs.writeFile(file, data, cb);
  });
}
function saveFile(backend, file, data, cb) {
  cb = typeof(cb) === 'function' ? cb : function () {};

  getBackendConfig(backend, function (err, config) {
    var datadir = config[':datadir'];
    file = path.join(datadir, file);

    fs.writeFile(file, data, cb);
  });
}
Saves data to a Hiera file.

@param {string} backend - the backend to load.
@param {string} file - the Hiera file to save to.
@param {Object} data - contents to save to the Hiera file.
@param {Function} cb - callback to invoke once file saving completes.

@example saveFile(
'gpg', '/path/to/file.gpg', fileData,
function (err) { ... }
);