awesome-logging
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -22,8 +22,8 @@ "use strict"; | ||
const stdin = process.stdin; | ||
stdin.setRawMode(true); | ||
stdin.resume(); | ||
stdin.setEncoding('utf8'); | ||
this._readStream = stdin.on('data', key => { | ||
this.changeKeyListener(undefined); | ||
stdin.on('data', (key) => { | ||
var _a; | ||
// ctrl-c ( end of text ) | ||
// ctrl-c / SIGINT ( end of text ) does not work with rawMode, so we handle it manually here | ||
//See https://nodejs.org/api/tty.html#tty_readstream_setrawmode_mode | ||
if (key.toString() === '\u0003') { | ||
@@ -39,5 +39,7 @@ process.exit(); | ||
if (!this._currentKeyListener) { | ||
process.stdin.setRawMode(false); | ||
process.stdin.pause(); | ||
} | ||
else { | ||
process.stdin.setRawMode(true); | ||
process.stdin.resume(); | ||
@@ -44,0 +46,0 @@ } |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const awesome_logger_1 = require("./awesome-logger"); | ||
awesome_logger_1.AwesomeLogger.log('this is awesome logging!'); | ||
setInterval(() => { | ||
awesome_logger_1.AwesomeLogger.interrupt('interrupt' + Math.random()); | ||
}, 4000); | ||
const promptForLog = () => { | ||
const a = awesome_logger_1.AwesomeLogger.prompt('choice', { | ||
options: ['text', 'spinner', 'progressbar', 'placeholder1', 'placeholder2', 'placeholder3', 'placeholder4', 'placeholder5'] | ||
}); | ||
a.result.then(x => { | ||
const logger = createExampleLogger(x); | ||
awesome_logger_1.AwesomeLogger.log(logger); | ||
setTimeout(() => { | ||
promptForLog(); | ||
}, 2000); | ||
}); | ||
}; | ||
promptForLog(); | ||
const createExampleLogger = (type) => { | ||
switch (type) { | ||
case 'text': { | ||
return awesome_logger_1.AwesomeLogger.create('text', { text: chalk_1.default.red('Example text') }); | ||
} | ||
case 'spinner': { | ||
return awesome_logger_1.AwesomeLogger.create('spinner', { | ||
text: ' My text', | ||
spinnerDelay: 75, | ||
spinnerFrames: [ | ||
chalk_1.default.magenta('■'), | ||
chalk_1.default.magenta('▄'), | ||
chalk_1.default.magenta('■'), | ||
chalk_1.default.magenta('▀'), | ||
chalk_1.default.magenta('▀'), | ||
chalk_1.default.yellow('■'), | ||
chalk_1.default.yellow('▄'), | ||
chalk_1.default.yellow('■'), | ||
chalk_1.default.yellow('▀'), | ||
chalk_1.default.yellow('▀') | ||
] | ||
}); | ||
} | ||
case 'progressbar': { | ||
return awesome_logger_1.AwesomeLogger.create('progress', { totalProgress: 100, filledColor: 'GREEN', maxWidth: 100 }); | ||
} | ||
} | ||
}; | ||
// setInterval(() => { | ||
// AwesomeLogger.interrupt('interrupt' + Math.random()); | ||
// }, 4000); | ||
// const promptForLog = () => { | ||
// const a = AwesomeLogger.prompt('choice', { | ||
// options: ['text', 'spinner', 'progressbar', 'placeholder1', 'placeholder2', 'placeholder3', 'placeholder4', 'placeholder5'] | ||
// }); | ||
// a.result.then(x => { | ||
// const logger = createExampleLogger(x)!; | ||
// AwesomeLogger.log(logger); | ||
// setTimeout(() => { | ||
// promptForLog(); | ||
// }, 2000); | ||
// }); | ||
// }; | ||
// promptForLog(); | ||
// const createExampleLogger = (type: string) => { | ||
// switch (type) { | ||
// case 'text': { | ||
// return AwesomeLogger.create('text', { text: chalk.red('Example text') }); | ||
// } | ||
// case 'spinner': { | ||
// return AwesomeLogger.create('spinner', { | ||
// text: ' My text', | ||
// spinnerDelay: 75, | ||
// spinnerFrames: [ | ||
// chalk.magenta('■'), | ||
// chalk.magenta('▄'), | ||
// chalk.magenta('■'), | ||
// chalk.magenta('▀'), | ||
// chalk.magenta('▀'), | ||
// chalk.yellow('■'), | ||
// chalk.yellow('▄'), | ||
// chalk.yellow('■'), | ||
// chalk.yellow('▀'), | ||
// chalk.yellow('▀') | ||
// ] | ||
// }); | ||
// } | ||
// case 'progressbar': { | ||
// return AwesomeLogger.create('progress', { totalProgress: 100, filledColor: 'GREEN', maxWidth: 100 }); | ||
// } | ||
// } | ||
// }; | ||
// const line1 = AwesomeLogger.create('text', { text: chalk.green('awd\nawd2awd3') }); | ||
@@ -54,0 +50,0 @@ // const prog1 = AwesomeLogger.create('progress', { totalProgress: 100, filledColor: 'GREEN', maxWidth: 100 }); |
{ | ||
"name": "awesome-logging", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Advanced logging messages, interactive prompts, loading animations and more in TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
123562
116
1790