api-doc-validator
Advanced tools
Comparing version 2.11.0 to 2.12.0
49
cli.js
@@ -24,3 +24,3 @@ #!/usr/bin/env node | ||
.option('-C, --default-code <code>', 'default @response CODE') | ||
.option('-S, --default-schemas <path>', 'path to js file with default schemas') | ||
.option('-S, --default-schemas <path...>', 'path to js file with default schemas', collect, null) | ||
.option('-J, --jsdoc-methods <boolean>', 'generate methods @type, default true') | ||
@@ -101,15 +101,25 @@ .option('-T, --jsdoc-typedefs <boolean>', 'generate @typedef, default true') | ||
if (config.defaultSchemas) { | ||
const defaultSchemasPaths = config.defaultSchemas && ( | ||
Array.isArray(config.defaultSchemas) ? | ||
config.defaultSchemas : | ||
[config.defaultSchemas] | ||
) || ['adv-parser/schemas']; | ||
for (const path of defaultSchemasPaths) { | ||
try { | ||
require.resolve(config.defaultSchemas); | ||
require.resolve(path); | ||
} | ||
catch (err) { | ||
throw new Error(`Default schemas file not found: ${JSON.stringify(config.defaultSchemas)}`); | ||
throw new Error(`Default schemas file not found: ${JSON.stringify(path)}`); | ||
} | ||
} | ||
const defaultSchemas = require(config.defaultSchemas || 'adv-parser/schemas'); | ||
const defaultSchemas = {}; | ||
var files = getFiles(config.include); | ||
for (const path of defaultSchemasPaths) { | ||
Object.assign(defaultSchemas, require(path)); | ||
} | ||
let files = getFiles(config.include); | ||
if (config.exclude) { | ||
@@ -216,5 +226,20 @@ let exclude = getFiles(config.exclude); | ||
function resolvePath(target, src, props) { | ||
for (let prop of props) { | ||
let path = src[prop] || target[prop]; | ||
target[prop] = path && resolve(configDir, path); | ||
const conv = (path) => { | ||
if (path.charAt(0) !== '.') { | ||
try { | ||
require.resolve(path); | ||
return path; | ||
} | ||
catch (e) {} | ||
} | ||
return resolve(configDir, path); | ||
}; | ||
for (const prop of props) { | ||
const path = src[prop] || target[prop]; | ||
target[prop] = path && ( | ||
Array.isArray(path) ? path.map(conv) : conv(path) | ||
); | ||
} | ||
@@ -234,2 +259,8 @@ } | ||
} | ||
} | ||
function collect(value, previous) { | ||
previous = previous || []; | ||
return previous.concat([value]); | ||
} |
{ | ||
"name": "api-doc-validator", | ||
"version": "2.11.0", | ||
"version": "2.12.0", | ||
"description": "api doc and validator", | ||
@@ -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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
59986
1685
10