deltamualpha / metalsmith-timer

A metalsmith plugin to output timings for each step in your build path.
6 stars 1 forks source link

DEBUG=metalsmith-timer #1

Open ghost opened 8 years ago

ghost commented 8 years ago

Hi!

Can you please explain me how exactly am I supposed to add DEBUG=metalsmith-timer to the call?

Thank you!

deltamualpha commented 8 years ago

It's an environment variable; the module uses https://github.com/visionmedia/debug under the hood. See that repo for a discussion of precisely how to set it for your environment.

ghost commented 8 years ago

Thanks a lot! It was a bit confusing, but I managed to make it work.

Any idea if there's a cross-platform solution for this? I made it work just for Windows, and I don't think it's the most elegant solution. Check out the build script in package.json, in my repo: https://github.com/dudezilla80/Metalsmith-Boilerplate/

deltamualpha commented 8 years ago

Well, since there's no way to have logic in your package.json file, you can't make it cross-platform there. If you're always going to run it, you could just set process.env.DEBUG='metalsmith-timer' inside your build javascript file.

ghost commented 8 years ago

I'd pretty much prefer that it always ran. I'd like to use it for a watcher task that would be pretty verbose when it ran.

It seems like I still can't make it work, even if I set process.env.DEBUG='metalsmith-timer' inside the build file. Could you please take a look at the tryDebug branch?

deltamualpha commented 8 years ago

Ah, if you move the process.env.DEBUG='metalsmith-timer' to a line above where you include metalsmith-timer, it works. debug initializes which modules to fire debug messages for at the moment it's included, and if you modify the environment after that, it doesn't see it.

process.env.DEBUG='metalsmith-timer';

var Metalsmith = require('metalsmith'),
    layouts = require('metalsmith-layouts'),
    timer = require('metalsmith-timer');

Metalsmith(__dirname)
...
andreyrd commented 6 years ago

cross-env solves the problem of setting environment variables cross platform