jonschlinkert / grunt-readme

DEPRECATED. Use Verb instead
https://github.com/assemble/verb
Other
30 stars 10 forks source link

_.mixin({include:... overrides _.include #49

Closed smithje closed 10 years ago

smithje commented 10 years ago

The include mixin at line 177 of the readme.js:

      include: function (filepath, sep) {
        sep = sep || options.sep;
        var includesPath = path.join(templates('includes'), filepath);
        return glob.content(includesPath, sep).replace(/^#/gm, '##');
      }

overrides underscore's include, which is an alias of _.contains.

I have registered a build task in grunt that is failing because it contains tasks from both grunt-readme and grunt-contrib-compress, which uses _.include. I can run either of these tasks independently, but if I try to run them together, I get this warning:

Warning: Arguments to path.join must be strings Use --force to continue.

Aborted due to warnings.

Unfortunately, grunt-contrib-compress has to come after grunt-readme, because I'm creating a tar of all of my files.

Here's a very minimal example:

package.json:

{
 "name": "GruntTest",
 "version": "0.0.0",
 "dependencies": {},
 "devDependencies": {
   "load-grunt-tasks": "~0.2.0",
   "grunt-readme": "~0.4.5",
   "grunt-contrib-compress": "~0.7.0"
 }
}

Gruntfile.js:

module.exports = function(grunt) {
    require('load-grunt-tasks')(grunt)
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        'compress': {
            options: {
              archive: 'build.tgz',
              mode: 'tgz'
            },
            files: ['README.md']
        }
    });
    grunt.registerTask('build', [
        'readme',
        'compress'
    ]);
};

Which outputs:

% grunt --stack build
Running "readme" task
>> Created README.md

Running "compress:files" (compress) task
Warning: Arguments to path.join must be strings Use --force to continue.
TypeError: Arguments to path.join must be strings
    at path.js:360:15
    at Array.filter (native)
    at Object.exports.join (path.js:358:36)
    at Function._.mixin.include (/Users/jsmith/qqq/grunttest/node_modules/grunt-readme/tasks/readme.js:179:33)
    at Object.<anonymous> (/Users/jsmith/qqq/grunttest/node_modules/grunt-contrib-compress/tasks/compress.js:27:22)
    at Object.<anonymous> (/Users/jsmith/qqq/grunttest/node_modules/grunt/lib/grunt/task.js:264:15)
    at Object.thisTask.fn (/Users/jsmith/qqq/grunttest/node_modules/grunt/lib/grunt/task.js:82:16)
    at Object.<anonymous> (/Users/jsmith/qqq/grunttest/node_modules/grunt/lib/util/task.js:282:30)
    at Task.runTaskFn (/Users/jsmith/qqq/grunttest/node_modules/grunt/lib/util/task.js:235:24)
    at Task.<anonymous> (/Users/jsmith/qqq/grunttest/node_modules/grunt/lib/util/task.js:281:12)

Aborted due to warnings.

Note the grunt-readme in the stack is being called during the compress task.

doowb commented 10 years ago

@jonschlinkert we might be able to use _.runInContext() for this.

jonschlinkert commented 10 years ago

I was going to suggest the same. This is why I put the mixins on _.fn in Phaser (I think I kept that in, need to double check). Speaking of which, this issue is timely in a way (I guess it's never timely have have an issue...).

However, grunt-readme will be powered by Phaser now. we'll also be releasing a grunt-phaser task and gulp-phaser.

@smithje we just pushed it up so it still needs some work, but feedback is welcome.

jonschlinkert commented 10 years ago

Closing since this repo has been deprecated. We created a new and improved version of this: Verb, along with grunt and gulp tasks, a cli and a generator. It does what grunt-readme does, but super easy to use (requiring zero config) and waaaay more powerful for anyone who wants more than the defaults. If you like the idea of what grunt-readme does, or should do, please give Verb a look!