fix less task overwriting grunt.config.data object #27

Merged
merged 1 commit into from Mar 26, 2014

Projects

None yet

2 participants

@johnyb
Contributor
johnyb commented Mar 26, 2014

Commit 0729eeb changed one call to
_.merge so it would overwrite the grunt.config.data object. This reverts
this one line accordingly.

Problem

metadata = _.merge({}, grunt.config.data, metadata,
                   grunt.task.current.data.options);

_.merge (see lodash documentation) overwrites the
first argument, since this is used as the destination. Using just
a clean object as destination, _.merge will also return the destination
object and store this result into metadata.

Overwriting grunt.config.data is a big problem if the less task is
used in combination with other tasks like compress from the
grunt-contrib-compress library. There is a compress option for
assemble-less, that will be available in
grunt.task.current.data.options. Merging this into grunt.config.data
will then overwrite the configuration of the compress task (with true
in this case). Leading to a very strange error message from grunt, since
some kind of object is expected there.

@johnyb @johnyb johnyb fix less task overwriting grunt.config.data object
Commit 0729eeb changed one call to
_.merge so it would overwrite the grunt.config.data object. This reverts
this one line accordingly.

Problem
=======

    metadata = _.merge({}, grunt.config.data, metadata,
                       grunt.task.current.data.options);

_.merge (see [0](http://lodash.com/docs#merge)) overwrites the
first argument, since this is used as the destination. Using just
a clean object as destination, _.merge will also return the destination
object and store this result into metadata.

Overwriting grunt.config.data is a big problem if the `less` task is
used in combination with other tasks like `compress` from the
grunt-contrib-compress library. There is a `compress` option for
assemble-less, that will be available in
`grunt.task.current.data.options`. Merging this into grunt.config.data
will then overwrite the configuration of the compress task (with `true`
in this case). Leading to a very strange error message from grunt, since
some kind of object is expected there.
98dccd3
@jonschlinkert
Member

good catch! thanks!

@jonschlinkert
Member

merging despite the failed Travis CI build, I don't think it's related.

@jonschlinkert jonschlinkert merged commit 529d248 into assemble:master Mar 26, 2014

1 check failed

default The Travis CI build failed
Details
@johnyb
Contributor
johnyb commented Mar 26, 2014

Yes, this test has been failing before :/ but I was unsure how to fix it.

@johnyb johnyb deleted the Open-Xchange-Frontend:grunt_config_overwritten branch Mar 26, 2014
@jonschlinkert
Member

no prob, I'll get it fixed, I think it's a less.js issue. thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment