Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overeager files interpretation in multi-tasks #1773

Open
RolKau opened this issue Apr 15, 2024 · 0 comments
Open

Overeager files interpretation in multi-tasks #1773

RolKau opened this issue Apr 15, 2024 · 0 comments

Comments

@RolKau
Copy link

RolKau commented Apr 15, 2024

If a multi-task is registered, and this multi-task is invoked with a section which is an array while grunt is run with the --verbose
option, the build will terminate with the error message:

Warning: pattern.indexOf is not a function Use --force to continue.

The exception itself is thrown at line 45 in file.js, but it comes from task.normalizeMultiTaskFiles at line 168 in task.js
where src is now [1, 2, 3] when it processes the foo section, because line 110 in task.js interprets the foo section as if it was a file specification in a non-multi-task, and creates an object with src=[1, 2, 3] and dest='foo'.

Consider the example from the documentation:

module.exports = grunt => {
  grunt.initConfig({
    log: {
      foo: [1, 2, 3],
      bar: 'hello world',
      baz: false
    }
  });

  grunt.task.registerMultiTask('log', 'Log stuff.', function() {
    grunt.log.writeln(this.target + ': ' + this.data);
  });
}

Given now also a package.json of:

{
  "main": "index.js",
  "scripts": {
    "build": "grunt log",
    "verbose": "grunt log --verbose"
  },
  "devDependencies": {
    "grunt": "1.6.1"
  }
}

one can reproduce the error with:

npm i
npm run build
npm run verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant