<commit_before>module.exports.safe = false;

/*
Purpose:
  Saves the HTTP body content (or the value of the .content property) to a file.
 */
var _ = require("lodash");
var fs = require("fs");
var mkdirp = require("mkdirp");
var path = require("path");
var Promise = require("bluebird");
var verror = require("verror");

module.exports.normalize = function normalize(action) {
	if(_.has(action, "save")) {
		if(_.isString(action.save)) {
			action.save = { filename: action.save };
		}
		if(_.has(action, "content")) {
			if(_.has(action, "target")) {
				throw new verror.VError({
					name: "InvalidActionConfiguration.save",
					info: {
						path: action.path
					}
				}, ".content is an alias for .target, so both cannot be specified for save actions");
			}
			action.target = action.content;
			delete(action.content);
		}
		return action;
	}
}

module.exports.process = function process(context) {
	var content;
	if(_.has(this.save, "target")) {
		content = this.save.target;
	}
	else {
		var response = context.getSessionValue("hyperpotamus.response", null, undefined);
		if (_.isNil(response)) {
			throw new verror.VError({
				name: "InvalidActionPlacement.save",<commit_msg>Fixed error with save action looking for target or content properties one level too high.<commit_after>module.exports.safe = false;

/*
Purpose:
  Saves the HTTP body content (or the value of the .content property) to a file.
 */
var _ = require("lodash");
var fs = require("fs");
var mkdirp = require("mkdirp");
var path = require("path");
var Promise = require("bluebird");
var verror = require("verror");

module.exports.normalize = function normalize(action) {
	if(_.has(action, "save")) {
		if(_.isString(action.save)) {
			action.save = { filename: action.save };
		}
		if(_.has(action.save, "content")) {
			if(_.has(action.save, "target")) {
				throw new verror.VError({
					name: "InvalidActionConfiguration.save",
					info: {
						path: action.path
					}
				}, ".content is an alias for .target, so both cannot be specified for save actions");
			}
			action.save.target = action.save.content;
			delete(action.save.content);
		}
		return action;
	}
}

module.exports.process = function process(context) {
	var content;
	if(_.has(this.save, "target")) {
		content = this.save.target;
	}
	else {
		var response = context.getSessionValue("hyperpotamus.response", null, undefined);
		if (_.isNil(response)) {
			throw new verror.VError({
				name: "InvalidActionPlacement.save",
{'fraction_non_alphanumeric': 0.14913341394598953, 'fraction_numerical': 0.0, 'mean_word_length': 3.857142857142857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6112249', 'n_tokens_mistral': 889, 'n_tokens_neox': 786, 'n_words': 209}