Skip to content

Commit

Permalink
Fixed a node v12 compatibility issue
Browse files Browse the repository at this point in the history
  • Loading branch information
75lb committed Aug 31, 2024
1 parent 0e3c820 commit db480f1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
8 changes: 4 additions & 4 deletions dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ const { __dirname: __dirname$1 } = currentModulePaths((typeof document === 'unde

class JsdocCommand {
constructor (options = {}, cache) {
options.files = arrayify(options.files);
options.source = arrayify(options.source);
assert.ok(
options.files?.length || options.source || options.configure,
options.files.length || options.source.length || options.configure,
'Must set at least one of .files, .source or .configure'
);
options.files = arrayify(options.files);
options.source = arrayify(options.source);

this.cache = cache;
this.tempFiles = [];
Expand Down Expand Up @@ -308,7 +308,7 @@ class JsdocOptions {
this.readme = options.readme;

/* Warning to avoid a common mistake where dmd templates are passed in.. a jsdoc template must be a filename. */
if (options.template !== undefined && options.template?.split(/\r?\n/)?.length !== 1) {
if (typeof options.template === 'string' && options.template.split(/\r?\n/).length !== 1) {
console.warn('Suspicious `options.template` value - the jsdoc `template` option must be a file path.');
console.warn(options.template);
}
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class JsdocOptions {
this.readme = options.readme

/* Warning to avoid a common mistake where dmd templates are passed in.. a jsdoc template must be a filename. */
if (options.template !== undefined && options.template?.split(/\r?\n/)?.length !== 1) {
if (typeof options.template === 'string' && options.template.split(/\r?\n/).length !== 1) {
console.warn('Suspicious `options.template` value - the jsdoc `template` option must be a file path.')
console.warn(options.template)
}
Expand Down
6 changes: 3 additions & 3 deletions lib/jsdoc-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ const { __dirname } = currentModulePaths(import.meta.url)

class JsdocCommand {
constructor (options = {}, cache) {
options.files = arrayify(options.files)
options.source = arrayify(options.source)
assert.ok(
options.files?.length || options.source || options.configure,
options.files.length || options.source.length || options.configure,
'Must set at least one of .files, .source or .configure'
)
options.files = arrayify(options.files)
options.source = arrayify(options.source)

this.cache = cache
this.tempFiles = []
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion test/lib/fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class Fixture {
static createTmpFolder (folder) {
try {
fs.statSync(folder)
fs.rmSync(folder, { recursive: true })
/* rmdirSync is node v12 friendly */
fs.rmdirSync(folder, { recursive: true })
fs.mkdirSync(folder)
} catch (err) {
fs.mkdirSync(folder)
Expand Down

0 comments on commit db480f1

Please sign in to comment.