refactor: move tag initialization out of runCommand()

This commit is contained in:
Jeff Williams 2024-02-21 13:50:06 -08:00
parent 3c68ce4267
commit cee9fbf914
No known key found for this signature in database
4 changed files with 13 additions and 8 deletions

7
package-lock.json generated
View File

@ -5541,9 +5541,9 @@
}
},
"node_modules/ip": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz",
"integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz",
"integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==",
"dev": true
},
"node_modules/is-arrayish": {
@ -12524,6 +12524,7 @@
"dependencies": {
"@jsdoc/doclet": "^0.2.10",
"@jsdoc/parse": "^0.3.10",
"@jsdoc/tag": "^0.2.10",
"cosmiconfig": "^9.0.0",
"escape-string-regexp": "^5.0.0",
"fast-glob": "^3.3.2",

View File

@ -20,6 +20,7 @@ import path from 'node:path';
import { augment, Package, resolveBorrows } from '@jsdoc/doclet';
import { createParser, handlers } from '@jsdoc/parse';
import { Dictionary } from '@jsdoc/tag';
import glob from 'fast-glob';
import stripJsonComments from 'strip-json-comments';
@ -173,11 +174,13 @@ export default class Api {
// TODO: docs; mention that filepaths overrides env.sourceFiles
async parseSourceFiles(filepaths) {
const { log, options } = this.env;
const parser = await this.#createParser();
let parser;
let packageData = '';
let packageDocs;
let docletStore;
this.env.tags = Dictionary.fromConfig(this.env);
parser = await this.#createParser();
docletStore = parser.parse(filepaths ?? this.env.sourceFiles, options.encoding);
if (options.package) {

View File

@ -33,6 +33,7 @@
"dependencies": {
"@jsdoc/doclet": "^0.2.10",
"@jsdoc/parse": "^0.3.10",
"@jsdoc/tag": "^0.2.10",
"cosmiconfig": "^9.0.0",
"escape-string-regexp": "^5.0.0",
"fast-glob": "^3.3.2",

View File

@ -91,9 +91,6 @@ export default (() => {
let cmd;
const { options } = env;
// TODO: Move to `Api`.
env.tags = Dictionary.fromConfig(env);
// If we already need to exit with an error, don't do any more work.
if (engine.shouldExitWithError) {
cmd = () => Promise.resolve(0);
@ -119,7 +116,10 @@ export default (() => {
// TODO: docs
cli.runTests = async () => {
const result = await test(env);
let result;
env.tags = Dictionary.fromConfig(env);
result = await test(env);
return result.overallStatus === 'failed' ? 1 : 0;
};