jasmine-ts
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -5,2 +5,9 @@ # Changelog | ||
### [0.3.3](https://github.com/svi3c/jasmine-ts/compare/v0.3.2...v0.3.3) (2021-04-25) | ||
### Bug Fixes | ||
* reworked the CLI parameter processing ([#61](https://github.com/svi3c/jasmine-ts/issues/61)) ([d6c28bf](https://github.com/svi3c/jasmine-ts/commit/d6c28bfb30ec414fceedb2a513918cd80607b74a)) | ||
### [0.3.2](https://github.com/ert78gb/jasmine-ts/compare/v0.3.1...v0.3.2) (2021-03-09) | ||
@@ -7,0 +14,0 @@ |
203
lib/index.js
@@ -6,26 +6,136 @@ #!/usr/bin/env node | ||
const ts_node_1 = require("ts-node"); | ||
const yargs_1 = require("yargs"); | ||
const yargs = require("yargs"); | ||
const argv = yargs | ||
.scriptName('jasmine-ts') | ||
.usage('$0 [options]') | ||
.option('r', { | ||
alias: 'require', | ||
describe: 'Require a node module before execution', | ||
}) | ||
.option('T', { | ||
alias: 'transpile-only', | ||
type: 'boolean', | ||
default: false, | ||
describe: '[ts-node] Use TypeScript\'s faster `transpileModule`' | ||
}) | ||
.option('I', { | ||
alias: 'ignore', | ||
describe: '[ts-node] Override the path patterns to skip compilation' | ||
}) | ||
.option('P', { | ||
alias: 'project', | ||
describe: '[ts-node] Path to TypeScript JSON project file' | ||
}) | ||
.option('C', { | ||
alias: 'compiler', | ||
describe: '[ts-node] Specify a custom TypeScript compiler' | ||
}) | ||
.option('D', { | ||
alias: 'ignore-diagnostics', | ||
describe: '[ts-node] Ignore TypeScript warnings by diagnostic code' | ||
}) | ||
.option('O', { | ||
alias: 'compiler-options', | ||
describe: '[ts-node] JSON object to merge with compiler options' | ||
}) | ||
.option('dir', { | ||
describe: '[ts-node] Specify working directory for config resolution' | ||
}) | ||
.option('scope', { | ||
describe: '[ts-node] Scope compiler to files within `cwd` only' | ||
}) | ||
.option('files', { | ||
describe: '[ts-node] Load `files`, `include` and `exclude` from `tsconfig.json` on startup' | ||
}) | ||
.option('pretty', { | ||
describe: '[ts-node] Use pretty diagnostic formatter (usually enabled by default)' | ||
}) | ||
.option('skip-project', { | ||
describe: '[ts-node] Skip reading `tsconfig.json`' | ||
}) | ||
.option('skip-ignore', { | ||
describe: '[ts-node] Skip `--ignore` checks' | ||
}) | ||
.option('prefer-ts-exts', { | ||
describe: '[ts-node] Prefer importing TypeScript files over JavaScript files' | ||
}) | ||
.option('log-error', { | ||
describe: '[ts-node] Logs TypeScript errors to stderr instead of throwing exceptions' | ||
}) | ||
.option('no-color', { | ||
describe: '[jasmine] Turn off color in spec output', | ||
type: 'boolean' | ||
}) | ||
.option('color', { | ||
describe: '[jasmine] Force turn on color in spec output', | ||
type: 'boolean' | ||
}) | ||
.option('filter', { | ||
describe: '[jasmine] Filter specs to run only those that match the given string' | ||
}) | ||
.option('helper', { | ||
describe: '[jasmine] Load helper files that match the given string' | ||
}) | ||
.option('stop-on-failure', { | ||
describe: '[jasmine] Stop spec execution on expectation failure', | ||
type: 'boolean' | ||
}) | ||
.option('fail-fast', { | ||
describe: '[jasmine] Stop Jasmine execution on spec failure', | ||
type: 'boolean' | ||
}) | ||
.option('config', { | ||
describe: '[jasmine] Path to your optional jasmine.json' | ||
}) | ||
.option('reporter', { | ||
describe: '[jasmine] Path to reporter to use instead of the default Jasmine reporter' | ||
}) | ||
.option('random', { | ||
describe: '[jasmine] Tells jasmine to run specs in semi random order or not for this run, overriding', | ||
type: 'boolean' | ||
}) | ||
.option('seed', { | ||
describe: '[jasmine] TSets the randomization seed if randomization is turned on', | ||
type: 'number' | ||
}) | ||
.alias('h', 'help') | ||
.alias('v', 'version') | ||
.help() | ||
.argv; | ||
const TS_NODE_OPTIONS = [ | ||
"fast", | ||
"lazy", | ||
"cache", | ||
"cacheDirectory", | ||
'require', | ||
"transpileOnly", | ||
"ignore", | ||
"project", | ||
"compiler", | ||
"project", | ||
"ignore", | ||
"ignoreWarnings", | ||
"disableWarnings", | ||
"getFile", | ||
"fileExists", | ||
"ignoreDiagnostics", | ||
"compilerOptions", | ||
"transpileOnly", | ||
"typeCheck", | ||
"dir", | ||
"scope", | ||
"files", | ||
"pretty", | ||
"skipProject", | ||
"skipIgnore", | ||
"preferTsExts", | ||
"logError" | ||
]; | ||
const tsNodeOptions = Object.assign({}, ...TS_NODE_OPTIONS.map((option) => { | ||
if (yargs_1.argv[option]) { | ||
return (option === "compilerOptions") | ||
? { compilerOptions: ts_node_1.parse(yargs_1.argv[option]) } | ||
: { [option]: yargs_1.argv[option] }; | ||
const tsNodeOptions = TS_NODE_OPTIONS.reduce((options, option) => { | ||
if (argv[option]) { | ||
if (option === "compilerOptions") { | ||
options[option] = ts_node_1.parse(argv[option]); | ||
} | ||
else if (option === 'require') { | ||
if (Array.isArray(argv[option])) { | ||
options[option] = argv[option]; | ||
} | ||
else { | ||
options[option] = [argv[option]]; | ||
} | ||
} | ||
else { | ||
options[option] = argv[option]; | ||
} | ||
} | ||
})); | ||
return options; | ||
}, {}); | ||
ts_node_1.register(tsNodeOptions); | ||
@@ -38,20 +148,43 @@ const Jasmine = require("jasmine"); | ||
const JASMINE_OPTIONS = [ | ||
'--no-color', | ||
'--color', | ||
'--filter=', | ||
'--helper=', | ||
'--require=', | ||
'--stop-on-failure=', | ||
'--fail-fast=', | ||
'--config=', | ||
'--reporter=' | ||
'no-color', | ||
'color', | ||
'filter', | ||
'helper', | ||
'stop-on-failure', | ||
'fail-fast', | ||
'config', | ||
'reporter', | ||
'random', | ||
'seed' | ||
]; | ||
function jasmineOptionsFilter(argOption) { | ||
return JASMINE_OPTIONS.some(option => argOption.startsWith(option)) | ||
|| !argOption.startsWith('--'); | ||
const commandOptions = JASMINE_OPTIONS | ||
.filter(option => option in argv) | ||
.map(option => { | ||
switch (option) { | ||
case 'color': | ||
return argv.color ? '--color' : '--no-color'; | ||
case 'no-color': | ||
return argv['no-color'] ? '--no-color' : undefined; | ||
case 'stop-on-failure': | ||
return argv['stop-on-failure'] ? '--stop-on-failure=true' : '--stop-on-failure=false'; | ||
case 'fail-fast': | ||
return argv['fail-fast'] ? '--fail-fast=true' : '--fail-fast=false'; | ||
case 'random': | ||
return argv.random ? '--random=true' : '--random=false'; | ||
default: | ||
return `--${option}=${argv[option]}`; | ||
} | ||
}) | ||
.filter(option => option !== undefined); | ||
const files = []; | ||
for (const arg of argv._) { | ||
if (typeof arg === 'string') { | ||
if (arg.startsWith('-')) | ||
break; | ||
files.push(arg); | ||
} | ||
else | ||
files.push(arg.toString()); | ||
} | ||
const commandOptions = process.argv | ||
.slice(2) | ||
.filter(jasmineOptionsFilter); | ||
command.run(jasmine, commandOptions); | ||
command.run(jasmine, [...commandOptions, ...files]); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "jasmine-ts", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "Execute jasmine with ts-node", | ||
@@ -11,3 +11,3 @@ "main": "lib/index.js", | ||
"lint": "tslint -p tsconfig.json", | ||
"jasmineTs": "node lib/index.js --config=spec/jasmine.json spec/jasmine-ts.spec.ts --transpileOnly --compilerOptions='{\"allowJs\": true}' --fake-option", | ||
"jasmineTs": "node lib/index.js --config=spec/jasmine.json spec/jasmine-ts.spec.ts", | ||
"test": "npm run lint && npm run compile && npm run jasmineTs", | ||
@@ -51,5 +51,6 @@ "prepublishOnly": "npm run compile", | ||
"@types/node": "^14.14.25", | ||
"@types/yargs": "^16.0.0", | ||
"@types/yargs": "^16.0.1", | ||
"dotenv": "^8.2.0", | ||
"jasmine": "^3.6.4", | ||
"jasmine-spec-reporter": "^6.0.0", | ||
"jasmine-spec-reporter": "^7.0.0", | ||
"rimraf": "^3.0.2", | ||
@@ -56,0 +57,0 @@ "standard-version": "^9.1.0", |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
21139
187
11