main.js
function SaveAllToConfig (src, callback, force = false) {
  let status = 1
  let message

  let resultError = function (message) {
    message = `Error: ${message}`
    log.error(message)
    callback(1, message)
  }

  let resultWarning = function (message) {
    message = `Warn: ${message}`
    log.warning(message)
    callback(0, message)
  }

  let addConfigDefinitions = function (jsonContent) {
    return jsonContent = 'profiles = ' +
      jsonContent +
      '\nexports.profiles = profiles;' +
      '\nexports.default = profiles.default;'
  }

  if (fs.existsSync(src) && !force) {
    return resultError('File exists, if you want to overwrite it, use the force attribute')
  } else {
    let contents = addConfigDefinitions(_InternalSerializeCurrentContext())
    fs.writeFile(src, contents, function (err) {
      if (err) {
        return resultError(err)
      } else {
        status = 0
        message = 'Success'
      }
      callback(status, message)
    })
  }
}
function SaveAllToConfig (src, callback, force = false) {
  let status = 1
  let message

  let resultError = function (message) {
    message = `Error: ${message}`
    log.error(message)
    callback(1, message)
  }

  let resultWarning = function (message) {
    message = `Warn: ${message}`
    log.warning(message)
    callback(0, message)
  }

  let addConfigDefinitions = function (jsonContent) {
    return jsonContent = 'profiles = ' +
      jsonContent +
      '\nexports.profiles = profiles;' +
      '\nexports.default = profiles.default;'
  }

  if (fs.existsSync(src) && !force) {
    return resultError('File exists, if you want to overwrite it, use the force attribute')
  } else {
    let contents = addConfigDefinitions(_InternalSerializeCurrentContext())
    fs.writeFile(src, contents, function (err) {
      if (err) {
        return resultError(err)
      } else {
        status = 0
        message = 'Success'
      }
      callback(status, message)
    })
  }
}
function SaveAllToConfig ( src , callback , force = false ) { let status = 1 let message let resultError = function ( message ) { message = ` ${ message } ` log . error ( message ) callback ( 1 , message ) } let resultWarning = function ( message ) { message = ` ${ message } ` log . warning ( message ) callback ( 0 , message ) } let addConfigDefinitions = function ( jsonContent ) { return jsonContent = 'profiles = ' + jsonContent + '\nexports.profiles = profiles;' + '\nexports.default = profiles.default;' } if ( fs . existsSync ( src ) && ! force ) { return resultError ( 'File exists, if you want to overwrite it, use the force attribute' ) } else { let contents = addConfigDefinitions ( _InternalSerializeCurrentContext ( ) ) fs . writeFile ( src , contents , function ( err ) { if ( err ) { return resultError ( err ) } else { status = 0 message = 'Success' } callback ( status , message ) } ) } }
Saves all the Environment, Detector, Notifiers and Filters information into a config file
@param {String} src is the path of the config file to use
@param {Function} callback is the callback function to call once the Save is all done, it passes
status and message as arguments to the function: \m
status = 0: Successfully has performed the action.
status = 1: Error: File exists already.
@param {Boolean} force true if the user wants to overwrite an already existing file.
Saves all the Environment Detector Notifiers and Filters information into a config file