/**
 * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

const upath = require( 'upath' );

/**
 * Stores HTML rendered by a pug template.
 * @type {module.HtmlFile}
 */
module.exports = class HtmlFile {
	/**
	 * @param {String} content Content of the file.
	 * @param {String} pathToFile Path to the file.
	 */
	constructor( content, pathToFile ) {
		this.content = content;
		this.basename = upath.basename( pathToFile );
		this.dirname = upath.dirname( pathToFile );
	}

	/**
	 * Returns path and filename as a merged string.
	 *
	 * @returns {String}
	 */
	get path() {
		if ( !this.basename || !this.dirname ) {
			return null;
		}

		return upath.join( this.dirname, this.basename );
	}
};
