{"size": 1053, "ext": "js", "max_stars_repo_path": "testutils/Actions/File/Move.js", "max_stars_repo_name": "paulondc/mebo", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "testutils/Actions/File/Move.js", "max_issues_repo_name": "paulondc/mebo", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "testutils/Actions/File/Move.js", "max_forks_repo_name": "paulondc/mebo", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.8679245283, "max_line_length": 75, "alphanum_fraction": 0.616334283}
const fs = require('fs');
const util = require('util');
const Mebo = require('../../../src');

const Action = Mebo.Action;

// promisifying
const rename = util.promisify(fs.rename);


/**
 * Moves the input file
 *
 * <h2>Input Summary</h2>
 *
 * Name | Required | Type | Default Value
 * --- | :---: | --- | ---
 * sourceFile | ::on:: | {@link FilePath} | ::none::
 * targetFile | ::on:: | {@link FilePath} | ::none::
 */
class Move extends Action{

  /**
   * Creates the action
   */
  constructor(){
    super();

    this.createInput('sourceFile: filePath', {exists: true});
    this.createInput('targetFile: filePath');
  }

  /**
   * Implements the execution of the action
   *
   * @param {Object} data - plain object containing the value of the inputs
   * @return {Promise<boolean>} boolean telling if the
   * file has been moved
   * @protected
   */
  async _perform(data){

    await rename(data.sourceFile, data.targetFile);

    return true;
  }
}

// Registering action
Mebo.Action.register(Move, 'file.move');

module.exports = Move;
