Skip to content

Commit db480f1

Browse files
committed
Fixed a node v12 compatibility issue
1 parent 0e3c820 commit db480f1

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

dist/index.cjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ const { __dirname: __dirname$1 } = currentModulePaths((typeof document === 'unde
4343

4444
class JsdocCommand {
4545
constructor (options = {}, cache) {
46+
options.files = arrayify(options.files);
47+
options.source = arrayify(options.source);
4648
assert.ok(
47-
options.files?.length || options.source || options.configure,
49+
options.files.length || options.source.length || options.configure,
4850
'Must set at least one of .files, .source or .configure'
4951
);
50-
options.files = arrayify(options.files);
51-
options.source = arrayify(options.source);
5252

5353
this.cache = cache;
5454
this.tempFiles = [];
@@ -308,7 +308,7 @@ class JsdocOptions {
308308
this.readme = options.readme;
309309

310310
/* Warning to avoid a common mistake where dmd templates are passed in.. a jsdoc template must be a filename. */
311-
if (options.template !== undefined && options.template?.split(/\r?\n/)?.length !== 1) {
311+
if (typeof options.template === 'string' && options.template.split(/\r?\n/).length !== 1) {
312312
console.warn('Suspicious `options.template` value - the jsdoc `template` option must be a file path.');
313313
console.warn(options.template);
314314
}

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class JsdocOptions {
140140
this.readme = options.readme
141141

142142
/* Warning to avoid a common mistake where dmd templates are passed in.. a jsdoc template must be a filename. */
143-
if (options.template !== undefined && options.template?.split(/\r?\n/)?.length !== 1) {
143+
if (typeof options.template === 'string' && options.template.split(/\r?\n/).length !== 1) {
144144
console.warn('Suspicious `options.template` value - the jsdoc `template` option must be a file path.')
145145
console.warn(options.template)
146146
}

lib/jsdoc-command.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ const { __dirname } = currentModulePaths(import.meta.url)
1010

1111
class JsdocCommand {
1212
constructor (options = {}, cache) {
13+
options.files = arrayify(options.files)
14+
options.source = arrayify(options.source)
1315
assert.ok(
14-
options.files?.length || options.source || options.configure,
16+
options.files.length || options.source.length || options.configure,
1517
'Must set at least one of .files, .source or .configure'
1618
)
17-
options.files = arrayify(options.files)
18-
options.source = arrayify(options.source)
1919

2020
this.cache = cache
2121
this.tempFiles = []

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/lib/fixture.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class Fixture {
2626
static createTmpFolder (folder) {
2727
try {
2828
fs.statSync(folder)
29-
fs.rmSync(folder, { recursive: true })
29+
/* rmdirSync is node v12 friendly */
30+
fs.rmdirSync(folder, { recursive: true })
3031
fs.mkdirSync(folder)
3132
} catch (err) {
3233
fs.mkdirSync(folder)

0 commit comments

Comments
 (0)