UNPKG

@netlify/content-engine

Version:
30 lines 1.26 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.detectPortInUseAndPrompt = void 0; const detect_port_1 = __importDefault(require("detect-port")); const reporter_1 = __importDefault(require("../reporter")); const prompts_1 = __importDefault(require("prompts")); const detectPortInUseAndPrompt = async (port, hostname) => { const detectedPort = await (0, detect_port_1.default)({ port, hostname }).catch((err) => reporter_1.default.panic(err)); if (port !== detectedPort) { reporter_1.default.log(`\nSomething is already running at port ${port}`); const response = await (0, prompts_1.default)({ type: `confirm`, name: `newPort`, message: `Would you like to run the app at another port instead?`, initial: true, }); if (response.newPort) { port = detectedPort; } else { throw new Error(`USER_REJECTED`); } } return port; }; exports.detectPortInUseAndPrompt = detectPortInUseAndPrompt; //# sourceMappingURL=detect-port-in-use-and-prompt.js.map