frontity
Version:
Frontity cli and entry point to other packages
25 lines (24 loc) • 1.02 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const serve_1 = __importDefault(require("../commands/serve"));
const utils_1 = require("../utils");
/**
* The serve CLI command, usually run with `npx frontity serve`.
*
* It takes args from the CLI and checks for the presence of environment
* variables. Then, it runs the serve command programatically.
*
* @param options - Defined in {@link ServeOptions}.
*/
const serve = async ({ port = process.env.FRONTITY_SERVE_PORT || "3000", https = !!process.env.FRONTITY_SERVE_HTTPS, }) => {
// Check `port` parameter.
if (port && Number.isNaN(parseInt(port, 10))) {
(0, utils_1.errorLogger)(new Error(`The port number specified is not valid: ${port}.`));
}
// Execute `serve` command.
(0, serve_1.default)({ port: parseInt(port, 10), https });
};
exports.default = serve;