node-ff
Version:
A CLI for creating NodeJs projects
42 lines • 1.84 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Prompts = exports.Prompt = void 0;
const prompt_1 = require("./prompt");
Object.defineProperty(exports, "Prompts", { enumerable: true, get: function () { return prompt_1.Prompts; } });
const readline_1 = __importDefault(require("readline"));
readline_1.default.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
class Prompt {
constructor(prompt) {
this.prompt = prompt;
}
execute() {
return __awaiter(this, void 0, void 0, function* () {
this.interrupt_process();
const response = yield this.prompt.start();
return response;
});
}
interrupt_process() {
process.stdin.on('keypress', (_str, key) => {
if (key.ctrl && key.name === 'c') {
console.log('\n\nProcesso finalizado!');
process.exit();
}
});
}
}
exports.Prompt = Prompt;
//# sourceMappingURL=index.js.map