quest-runner
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -81,3 +81,5 @@ #!/usr/bin/env node | ||
const code = '' + await fs.readFile(file); | ||
const { task, step, play } = require('./index.js'); | ||
const { task, step, play, mode } = require('./index.js'); | ||
if ((argv.task || []).length > 0) mode.task = argv.task; | ||
if ((argv.skip || []).length > 0) mode.skip = argv.skip; | ||
eval(code); | ||
@@ -84,0 +86,0 @@ const result = await play(argv ?? {}); |
45
index.js
@@ -35,2 +35,4 @@ | ||
const mode = {}; | ||
const task = (name, code, info) => { | ||
@@ -112,8 +114,42 @@ if (typeof name === 'function') { | ||
number++; | ||
if (task.info != undefined && typeof task.info === 'object') { | ||
if (typeof task.info.skip === 'boolean' && task.info.skip) { | ||
continue; | ||
let skip = false; | ||
if (task.info != undefined && typeof task.info === 'object') { | ||
if (task.info.skip === true) { | ||
skip = true; | ||
} | ||
} | ||
if (typeof mode.task === 'object' && Array.isArray(mode.task)) { | ||
const value = (task.name ?? '').toLowerCase(); | ||
skip = true; | ||
for (const check of mode.task) { | ||
if (value === check.toLowerCase()) { | ||
skip = false; | ||
break; | ||
} | ||
} | ||
} | ||
if (!skip && typeof mode.skip === 'object' && Array.isArray(mode.skip)) { | ||
const value = (task.name ?? '').toLowerCase(); | ||
for (const check of mode.skip) { | ||
if (value === check.toLowerCase()) { | ||
skip = true; | ||
break; | ||
} | ||
} | ||
} | ||
if (skip && task.info != undefined && typeof task.info === 'object') { | ||
if (task.info.always === true) { | ||
skip = false; | ||
} | ||
} | ||
if (skip) { | ||
continue; | ||
} | ||
console.log(`${ansi.blueBright('TASK')} ${ansi.bgBlue(' ' + ansi.whiteBright(number) + ' ')}${task.name ? ' ' : ''}${task.name}`); | ||
@@ -256,3 +292,4 @@ console.log(); | ||
step, | ||
play | ||
play, | ||
mode, | ||
}; |
const yargs = require('yargs/yargs') | ||
const argv = yargs(process.argv.slice(2)) | ||
const { hideBin } = require('yargs/helpers'); | ||
const argv = yargs(hideBin(process.argv)) | ||
.boolean('version') | ||
@@ -7,2 +8,6 @@ .boolean('help') | ||
.boolean('silent') | ||
.option('skip') | ||
.array('skip') | ||
.option('task') | ||
.array('task') | ||
.alias('V', 'version') | ||
@@ -14,3 +19,5 @@ .alias('?', 'help') | ||
.describe('silent', 'Silent mode') | ||
.describe('skip', 'Skip task (may be used more than once)') | ||
.describe('task', 'Run specified task (may be used more than once)') | ||
.parse(); | ||
module.exports = argv; |
{ | ||
"name": "quest-runner", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Tool for creating and processing logic flow scenarios", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
58710
1449