quest-runner
Advanced tools
Comparing version 0.1.5 to 0.1.6
{ | ||
"name": "quest-runner", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Tool for creating and processing logic flow scenarios", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
36
test.js
@@ -231,2 +231,6 @@ const ansi = require('ansi-colors'); | ||
squeeze(array, limit = 10, separator = '...') { | ||
return utils.squeeze(array, limit, separator); | ||
} | ||
timeout; | ||
@@ -347,3 +351,14 @@ | ||
if (options?.silent !== true) { | ||
console.log(`${ansi.magentaBright('CALL')} ${ansi.cyanBright(method)} ${ansi.yellowBright(url)}`); | ||
let anonymous = true; | ||
for (const header in request.headers) { | ||
if (header.toLowerCase() === 'authorization') { | ||
anonymous = false; | ||
break; | ||
} | ||
} | ||
if (anonymous) { | ||
console.log(`${ansi.greenBright('CALL')} ${ansi.blueBright(method)} ${ansi.yellowBright(url)}`); | ||
} else { | ||
console.log(`${ansi.magentaBright('CALL')} ${ansi.cyanBright(method)} ${ansi.yellowBright(url)}`); | ||
} | ||
console.log(); | ||
@@ -498,9 +513,14 @@ } | ||
}); | ||
process.stdin.setRawMode(true); | ||
process.stdin.resume(); | ||
const time = (options?.time ?? 10) * 1000; | ||
let query = options?.text; | ||
if (query == undefined) query = '' + | ||
if (query === undefined) query = '' + | ||
ansi.whiteBright('Press ') + | ||
ansi.greenBright('Enter ') + | ||
ansi.whiteBright('to continue... '); | ||
if (query != undefined && 0 === ('' + query).trim().length) query = undefined; | ||
let enter = false; | ||
try { | ||
if (query != undefined) process.stdout.write(query); | ||
await new Promise(resolve => { | ||
@@ -510,7 +530,12 @@ const ac = new AbortController(); | ||
signal.addEventListener('abort', () => { | ||
readline.moveCursor(process.stdout, 0, -1); | ||
resolve(); | ||
}, { once: true }); | ||
rl.question(query, { signal }, _answer => { | ||
rl.question(query ?? '', { signal }, _answer => { | ||
if (query != undefined) { | ||
readline.moveCursor(process.stdout, 0, -1); | ||
readline.clearLine(process.stdout, 1); | ||
} | ||
enter = true; | ||
resolve(); | ||
rl.close(); | ||
}); | ||
@@ -522,3 +547,4 @@ if (time > 0) setTimeout(() => ac.abort(), time); | ||
rl.close(); | ||
console.log(); | ||
process.stdin.setRawMode(false); | ||
if (query != undefined && !enter) console.log(); | ||
} | ||
@@ -525,0 +551,0 @@ } |
15
utils.js
@@ -118,4 +118,19 @@ class Utils { | ||
squeeze = (array, limit = 10, separator = '...') => { | ||
if (array == undefined) return array; | ||
if (typeof array !== 'object' || !Array.isArray(array)) return array; | ||
if (array.length <= limit) return array; | ||
if (separator == undefined) { | ||
const half = Math.floor(limit / 2); | ||
const result = [ ...array.slice(0, half), ...array.slice(half - limit) ]; | ||
return result; | ||
} else { | ||
const half = Math.floor((limit - 1) / 2); | ||
const result = [ ...array.slice(0, half), separator, ...array.slice(1 + half - limit) ]; | ||
return result; | ||
} | ||
}; | ||
} | ||
module.exports = new Utils; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57184
1410