"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

function _defineProperty2() {
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

  _defineProperty2 = function () {
    return data;
  };

  return data;
}

function _fsExtra() {
  const data = _interopRequireDefault(require("fs-extra"));

  _fsExtra = function () {
    return data;
  };

  return data;
}

function _constants() {
  const data = require("../../../constants");

  _constants = function () {
    return data;
  };

  return data;
}

function _() {
  const data = require(".");

  _ = function () {
    return data;
  };

  return data;
}

class License extends _().AbstractVinyl {
  constructor(...args) {
    super(...args);
    (0, _defineProperty2().default)(this, "override", true);
  }

  write() {
    if (!this.override && _fsExtra().default.existsSync(this.path)) return Promise.resolve();
    return _fsExtra().default.outputFile(this.path, this.contents);
  }

  serialize() {
    return this.contents.toString();
  }

  static deserialize(str) {
    return new License({
      path: _constants().LICENSE_FILENAME,
      contents: str ? Buffer.from(str) : null
    });
  }

}

exports.default = License;