ericclemmons / grunt-verbosity

Adjust verbosity for individual grunt tasks
MIT License
8 stars 4 forks source link

No Output Without `--verbose` #4

Open bobjackman opened 11 years ago

bobjackman commented 11 years ago

I'm trying to use this package, but running into an odd behavior. If I use any mode other than normal (i.e. oneline or dot), I just get a blank line of output:

Running "groundskeeper:default" (groundskeeper) task

However, if I use --verbose on the command line, then I do, indeed, see the behavior that I expect.

Do you see this issue? What info do you need from me?

ericclemmons commented 11 years ago

I'll check it out! I've noticed this issue with the full test-suite, but it worked last time I ran them individually.

I'll check again!

bobjackman commented 11 years ago

Any updates on this front?

ericclemmons commented 11 years ago

Dude, I've been messing with it for over an hour today and this crap isn't working.

Doing something as simple as the following doesn't even work!!

grunt.log.writeln = function(message) {
  console.log('Overrode', message);
  return grunt.log;
};

grunt.log.writeln("Message");
// undefined
ericclemmons commented 11 years ago

Nvm, more crap messing up, brb...

ericclemmons commented 11 years ago

I think I've got it fixed!

ericclemmons commented 11 years ago

Well crap, there's more to it. I'm going to rewrite this stupid thing to be simpler, since Hooker doesn't work as it should anymore.

So basically, I check grunt.log.header to figure out if the task has modified verbosity, then overwrite grunt.log.writeln to do whatever you want (DOT, ONELINE, HIDDEN, etc.), then bail back out when grunt.log.header, grunt.log.fail or grunt.log.success is called.

ericclemmons commented 11 years ago

In otherwords, I made it too complicated from the beginning by using Hooker.

ericclemmons commented 11 years ago

I just bumped to v0.2.0, which is a lot simpler code. Let me know how it works for you!

$ grunt
Running "jshint:all" (jshint) task
>> 3 files lint free.

Running "verbosity:hidden" (verbosity) task

Running "log:test" (log) task

Running "log:clear" (log) task
Log message #1

Running "verbosity:oneline" (verbosity) task

Running "log:test" (log) task
Log message #5
Running "log:clear" (log) task
Log message #1

Running "verbosity:normal" (verbosity) task

Running "log:test" (log) task
Log message #1
Log message #2
Log message #3
Log message #4
Log message #5

Running "log:clear" (log) task
Log message #1

Running "verbosity:dot" (verbosity) task

Running "log:test" (log) task
.....
Running "log:clear" (log) task
Log message #1
bobjackman commented 11 years ago

Thanks for updating! Just checked it out, but it looks like something is still getting fubar'd.

--verbose output

Registering "grunt-verbosity" local Npm module tasks.
Reading D:\Code\project\node_modules\grunt-verbosity\package.json...OK
Parsing D:\Code\project\node_modules\grunt-verbosity\package.json...OK
Loading "verbosity_task.js" tasks...OK
+ verbosity
Loading "Gruntfile.js" tasks...OK
+ _start, build:only, projectInfo

Running tasks: build:only

Running "build:only" task

Running "_start" task

Running "verbosity:default" (verbosity) task
Verifying property verbosity.default exists in config...OK
File: [no files]
Verifying property verbosity.default.tasks exists in config...OK
Warning: Cannot call method 'indexOf' of null Use --force to continue.

At this point it dies. Here are the relevant parts of my gruntfile (not the complete file)

gruntfile.js

module.exports = function( grunt ) {
    grunt.initConfig({
        verbosity: {
            default: {
                options: { mode: 'dot' }, // normal, oneline, dot, hidden
                tasks: ['groundskeeper', 'requirejs']
            }
        },

         // Remove any dev/debugging code
        groundskeeper: {
            default: { ... },
            options: { ... }
        },

        // Optimize modules using requirejs
        requirejs: {
            build: {
                options: { ... }
            }
        }
    });

    grunt.registerTask( '_start',  ['verbosity:default', 'projectInfo'] );

    grunt.registerTask( 'build:only', ['_start', 'groundskeeper', 'requirejs'] );

    grunt.loadNpmTasks('grunt-contrib-requirejs');
    grunt.loadNpmTasks('grunt-groundskeeper');
    grunt.loadNpmTasks('grunt-verbosity');
};
ericclemmons commented 11 years ago

Just published v0.2.1. Try now!

bobjackman commented 11 years ago

Still no go...

grunt build:only

Running "verbosity:default" (verbosity) task

Running "groundskeeper:default" (groundskeeper) task

Running "requirejs:build" (requirejs) task

Tracing dependencies for: app
Uglifying file: D:/Code/project/release/app.js

D:/Code/project/release/app.js
----------------
D:/Code/project/release/lib/jquery.js
D:/Code/project/release/lib/handlebars.js
D:/Code/project/release/lib/ember/ember.js
D:/Code/project/release/lib/require/text.js

<snip 500 lines>

timers.js:103
            if (!process.listeners('uncaughtException').length) throw e;
                                                                      ^
TypeError: Cannot read property 'length' of undefined
    at Verbosity.writeln (D:\Code\project\node_modules\grunt-verbosity\tasks\lib\verbosity.js:54:16)
    at Object.fail.report (D:\Code\project\node_modules\grunt\lib\grunt\fail.js:82:15)
    at Object.grunt.tasks.task.options.done (D:\Code\project\node_modules\grunt\lib\grunt.js:140:12)
    at Task.<anonymous> (D:\Code\project\node_modules\grunt\lib\util\task.js:261:25)
    at Task.<anonymous> (D:\Code\project\node_modules\grunt\lib\util\task.js:215:7)
    at Object.Task.runTaskFn.context.async [as _onTimeout] (D:\Code\project\node_modules\grunt\lib\util\task.js:225:33)
    at Timer.list.ontimeout (timers.js:101:19)
ericclemmons commented 11 years ago

BAM, v0.2.2. Turns out, you have a lot of undefined writeln() commands that I wasn't testing for.

TRY NOW, TROUBLEMAKER!

bobjackman commented 11 years ago

Looks like all the errors have been resolved, but now I'm just getting normal, full output, not "dots" as configured. I've also tried "oneline" and "hidden" but it just always outputs as if in "normal" mode.

What is it about what I'm doing that's so much different than how you're testing?

ericclemmons commented 11 years ago

You're not using the verbose flag every time are you?

Otherwise, I don't know what other scripts you're running to generate output. Perhaps they don't use grunt.log.writeln?

Eric Clemmons Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Monday, August 26, 2013 at 4:56 PM, KOGI wrote:

Looks like all the errors have been resolved, but now I'm just getting normal, full output, not "dots" as configured. I've also tried "oneline" and "hidden" but it just always outputs as if in "normal" mode. What is it about what I'm doing that's so much different than how you're testing?

— Reply to this email directly or view it on GitHub (https://github.com/ericclemmons/grunt-verbosity/issues/4#issuecomment-23298383).

bobjackman commented 11 years ago

No, I'm not using verbose. The only other scripts running are already down in my previous posts. Requirejs is making the most noise. ATM I have no idea the mechanism they're using for output.

ericclemmons commented 11 years ago

Your project wouldn't be open-source, would it? :)

Otherwise, I may need to wrap several other commands that are being used by requirejs. Does that seem right?

bobjackman commented 11 years ago

Unfortunately, although free, it's not open source. But my scripts aren't creating the output... Requires is making all the noise. Unless I'm missing something?

Eric Clemmons notifications@github.com wrote:

Your project wouldn't be open-source, would it? :)

Otherwise, I may need to wrap several other commands that are being used by requirejs. Does that seem right?

— Reply to this email directly or view it on GitHub.

ericclemmons commented 11 years ago

Could you at least setup a simple project for me to test against? I think I know the culprit, but it'll take a lot more for me to guess at what you're actual problem is rather than fixing your test case.

I figure a Gruntfile.js, package.json, grunt-verbosity, grunt-contrib-requirejs and some sample JS files would be enough, right?

ericclemmons commented 10 years ago

I may have to go back to grunt.util.hooker, which works now in grunt v0.4.2...