Skip to content

Commit 3bff4da

Browse files
authored
Fix jake -T for directory tasks
Not sure if exactly `directory` or `packageTask` related, I have both and it breaks when I `jake -T`, all tasks run well still. So looks like it needs not to break in the negative case for the regexp, when nothing was matched. This fixes the problem. Logged `this.action` and `this.action.name` and `this.action.toString()` values that break it. ``` $ jake -T [Function: action] { name: 'action', string: 'function () {\n jake.mkdirP(name);\n }' } jake aborted. TypeError: Cannot read properties of undefined (reading 'replace') at DirectoryTask._getParams (/Users/falsefalse/.nvm/versions/node/v16.16.0/lib/node_modules/jake/lib/task/task.js:428:10) ```
1 parent f600048 commit 3bff4da

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/task/task.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ class Task extends EventEmitter {
420420

421421
_getParams() {
422422
if (!this.action) return "";
423-
let params = new RegExp('(?:'+this.action.name+'\\s*|^)\\s*\\((.*?)\\)').exec(this.action.toString().replace(/\n/g, ''))[1].replace(/\/\*.*?\*\//g, '').replace(/ /g, '');
423+
let params = (new RegExp('(?:'+this.action.name+'\\s*|^)\\s*\\((.*?)\\)').exec(this.action.toString().replace(/\n/g, '')) || [,''])[1].replace(/\/\*.*?\*\//g, '').replace(/ /g, '');
424424
return params;
425425
}
426426

0 commit comments

Comments
 (0)