Your browser doesn’t support some of the latest CSS features used to build this site.

Read more about my usage of new CSS features.

A little Node package I wrote to print out a random curse when something goes wrong!

A friend of mine introduced me to Sindre Sorhus’ Superb Node package a little while ago so I took the concept, turned it on its head and created a small Node package that returns a random, funny curse phrase to your console or app - with the idea that it could be used for when a task goes disastrously wrong.

Dammit!

/ˈdamɪt/

exclamation informal

Used to express anger or frustration.

Installation

Installation couldn’t be easier - as with the majority of Node packages, simply enter:

npm install dammit --save-dev
Remember to pass the --save or --save-dev flag to save it in your package.json and your project.

Usage

There are currently two modes you can use dammit in - Safe and NSFW modes. As you can imagine, I’d recommend using Safe mode for your projects as NSFW mode was pretty much just introduced for Mr. Andy Blackledge’s dirty mouth.

To use it within a Node package or Grunt/Gulp task do the following:

var dammit = require('dammit');

console.log(dammit({'NSFW': false})); // Logs a safe one
console.log(dammit({'NSFW': true})); // Logs a naughty one

And that's it!

In the wild

Here’s an example paraphrased from our combine-mq package:

// Read file in
fs.readFile(options.src, 'utf8', function(err, fileContents) {
  if (err) {
    // Write error messages
    console.log(chalk.red(dammit({
      NSFW: false
    })));
    console.log(chalk.red('(Could not open file: "' + self.src + '")'));
    // Exit out
    process.exit(1);
  }
});

In this instance, if the file input to combine-mq doesn’t exist, error out and display a dammit phrase to the console.

Via the CLi

Alternatively you can have a play via the command line by installing as above and entering either

dammit

Or

dammit NSFW

TL;DR

I wrote a little Node package to return a random curse phrase - for use within other Node/Grunt/Gulp etc. tasks.

NPM badge for dammit showing downloads

Download Dammit! from the NPM registry or enter:

npm install dammit

…and away you go!

Contribute to the curses.json file by forking the GitHub repo.