@jsdoc/core
Advanced tools
Comparing version 0.5.6 to 0.5.7
@@ -16,2 +16,3 @@ /* | ||
*/ | ||
/** | ||
@@ -23,8 +24,7 @@ * Core functionality for JSDoc. | ||
import * as config from './lib/config.js'; | ||
import Dependencies from './lib/dependencies.js'; | ||
import env from './lib/env.js'; | ||
import Env from './lib/env.js'; | ||
import * as name from './lib/name.js'; | ||
import * as plugins from './lib/plugins.js'; | ||
export { config, Dependencies, env, name, plugins }; | ||
export default { config, Dependencies, env, name, plugins }; | ||
export { config, Env, name, plugins }; | ||
export default { config, Env, name, plugins }; |
@@ -21,3 +21,3 @@ /* | ||
*/ | ||
import { cosmiconfigSync, defaultLoaders } from 'cosmiconfig'; | ||
import { cosmiconfig, defaultLoaders } from 'cosmiconfig'; | ||
import _ from 'lodash'; | ||
@@ -98,3 +98,3 @@ import stripBom from 'strip-bom'; | ||
const explorerSync = cosmiconfigSync(MODULE_NAME, { | ||
const explorer = cosmiconfig(MODULE_NAME, { | ||
cache: false, | ||
@@ -118,9 +118,9 @@ loaders: { | ||
export function loadSync(filepath) { | ||
export async function load(filepath) { | ||
let loaded; | ||
if (filepath) { | ||
loaded = explorerSync.load(filepath); | ||
loaded = await explorer.load(filepath); | ||
} else { | ||
loaded = explorerSync.search() || {}; | ||
loaded = (await explorer.search()) ?? {}; | ||
} | ||
@@ -127,0 +127,0 @@ |
145
lib/env.js
@@ -16,2 +16,7 @@ /* | ||
*/ | ||
import EventEmitter from 'node:events'; | ||
import { getLogFunctions } from '@jsdoc/util'; | ||
/** | ||
@@ -21,58 +26,96 @@ * Data about the environment in which JSDoc is running, including the configuration settings that | ||
* | ||
* @alias @jsdoc/core.env | ||
* @alias @jsdoc/core.Env | ||
*/ | ||
export default { | ||
/** | ||
* The times at which JSDoc started and finished. | ||
* | ||
* @type {Object} | ||
* @property {Date} start - The time at which JSDoc started running. | ||
* @property {Date} finish - The time at which JSDoc finished running. | ||
*/ | ||
run: { | ||
start: new Date(), | ||
finish: null, | ||
}, | ||
export default class Env { | ||
constructor() { | ||
/** | ||
* The command-line arguments passed to JSDoc. | ||
* | ||
* @type {Array<*>} | ||
*/ | ||
this.args = process.argv.slice(2); | ||
/** | ||
* The command-line arguments passed to JSDoc. | ||
* | ||
* @type {Array<*>} | ||
*/ | ||
args: [], | ||
/** | ||
* The data parsed from JSDoc's configuration file. | ||
* | ||
* @type Object<string, *> | ||
*/ | ||
this.conf = {}; | ||
/** | ||
* The data parsed from JSDoc's configuration file. | ||
* | ||
* @type Object<string, *> | ||
*/ | ||
conf: {}, | ||
/** | ||
* The event emitter shared across JSDoc. | ||
* | ||
* @type {Object} | ||
*/ | ||
this.emitter = new EventEmitter(); | ||
/** | ||
* The command-line arguments, parsed into a key/value hash. | ||
* | ||
* @type {Object} | ||
* @example if (global.env.opts.help) { console.log('Helpful message.'); } | ||
*/ | ||
opts: {}, | ||
/** | ||
* Logging functions shared across JSDoc. | ||
* | ||
* @type {Object<string, function>} | ||
*/ | ||
this.log = getLogFunctions(this.emitter); | ||
/** | ||
* The source files that JSDoc will parse. | ||
* | ||
* @type {Array<string>} | ||
* @memberof env | ||
*/ | ||
sourceFiles: [], | ||
/** | ||
* The command-line arguments, parsed into a key/value hash. | ||
* | ||
* @type {Object} | ||
* @example if (global.env.opts.help) { console.log('Helpful message.'); } | ||
*/ | ||
this.opts = {}; | ||
/** | ||
* The JSDoc version number and revision date. | ||
* | ||
* @type {Object<string, string>} | ||
* @property {string} number - The JSDoc version number. | ||
* @property {string} revision - The JSDoc revision number, expressed as a UTC date string. | ||
*/ | ||
version: { | ||
number: null, | ||
revision: null, | ||
}, | ||
}; | ||
/** | ||
* The times at which JSDoc started and finished. | ||
* | ||
* @type {Object} | ||
* @property {Date} start - The time at which JSDoc started running. | ||
* @property {Date} finish - The time at which JSDoc finished running. | ||
*/ | ||
this.run = { | ||
start: new Date(), | ||
finish: null, | ||
}; | ||
/** | ||
* The source files that JSDoc will parse. | ||
* | ||
* @type {Array<string>} | ||
*/ | ||
this.sourceFiles = []; | ||
/** | ||
* The dictionary of tags recognized by JSDoc. | ||
* | ||
* @type {module:@jsdoc/tags.Dictionary} | ||
*/ | ||
this.tags = null; | ||
/** | ||
* The JSDoc version number and revision date. | ||
* | ||
* @type {Object<string, string>} | ||
* @property {string} number - The JSDoc version number. | ||
* @property {string} revision - The JSDoc revision number, expressed as a UTC date string. | ||
*/ | ||
this.version = { | ||
number: null, | ||
revision: null, | ||
}; | ||
} | ||
get config() { | ||
return this.conf; | ||
} | ||
get env() { | ||
return this; | ||
} | ||
get(key) { | ||
return this[key]; | ||
} | ||
get options() { | ||
return this.opts; | ||
} | ||
} |
{ | ||
"name": "@jsdoc/core", | ||
"version": "0.5.6", | ||
"version": "0.5.7", | ||
"description": "Core functionality for JSDoc.", | ||
@@ -34,3 +34,2 @@ "keywords": [ | ||
"dependencies": { | ||
"bottlejs": "^2.0.1", | ||
"cosmiconfig": "^9.0.0", | ||
@@ -45,3 +44,3 @@ "escape-string-regexp": "^5.0.0", | ||
}, | ||
"gitHead": "3e4f5fc5570472d398a6a28d2b6080e8ec7cdfb5" | ||
"gitHead": "db20d510665ac4ca9a363c08ea95e4ae88c09c4a" | ||
} |
5
35263
8
750
- Removedbottlejs@^2.0.1
- Removedbottlejs@2.0.1(transitive)