Example #1
0
module.exports = function(text, cb) {
  var callback = function(err, data) {
    // Defaults to writing the message to the console. In green.
    console.log(data.green);
    // Just a blank line.
    console.log("\n");
    // And the line that used to be the "hooray" message.
    console.log('You\'ve finished all the challenges! Hooray!\n');
    if (cb) {
      cb(err, data);
    }
  };
  // Support callback as only parameter.
  if (typeof(text) === 'function') {
    cb = text;
    text = undefined;
  }
  if (!text) {
    text = util.format('%s \n %s',
                         word1[Math.floor(Math.random() * word1.length)],
                         word2[Math.floor(Math.random() * word2.length)]);
  }

  figlet.text(text, {
    font: 'ANSI Shadow',
    horizontalLayout: 'default',
    verticalLayout: 'default'
  }, callback);
};
Example #2
0
function showText({ text, font }) {
  figlet.text(
    text,
    { font: font || 'AMC Razor' },
    (err, graffiti) => console.log(chalk.red(font), '\n', graffiti)
  );
}
Example #3
0
    grunt.registerMultiTask('figlet', 'Adds ASCII Art banners to source code.', function() {
        var options = this.options(),
            target = this.target,
            inputText,
            fontOpts = figlet.defaults(),
            done = this.async();
        
        // set what the input text will be
        if (typeof this.data === 'string') {
            inputText = this.data;
        } else if (options.text) {
            inputText = options.text;
        } else {
            inputText = '';
        }
        
        fontOpts.font = (options.font) ? options.font : fontOpts.font;
        fontOpts.horizontalLayout = (options.horizontalLayout) ? options.horizontalLayout : fontOpts.horizontalLayout;
        fontOpts.verticalLayout = (options.verticalLayout) ? options.verticalLayout : fontOpts.verticalLayout;

        figlet.text(inputText, fontOpts, function(err, data) {
            if (err) {
                done(err);
                return;
            }

            var genFunct, 
                outText = data,
                comment = options.comment;

            /*
                Handle if the user has setup a comment block
            */
            if (typeof comment === 'object' && comment) {
                if (typeof comment.style === 'function') {
                    genFunct = comment.style;
                } else if (comment.style) {
                    genFunct = commentFuncts[comment.style];
                    if (typeof genFunct === 'undefined') {
                        throw new Error('Unknown comment type.');
                    }
                } else {
                    genFunct = commentFuncts['js']; // default
                }

                if (typeof comment.generate === 'function') {
                    outText = comment.generate(outText);
                }
                outText = genFunct(outText);
            }

            var figletObj = grunt.config.get('figlet') || {};
            figletObj[target] = outText;
            grunt.config.set('figlet', figletObj);

            grunt.log.writeln('Banner for '+target+' generated.');
            done(err);
        });
    });
Example #4
0
server.listen(process.env.PORT || config.get('port'), function() {
  figlet.text('connect', function(err, date) {
    if (err) {
      return console.log(err);
    } else {
      console.log(date);
    }
  });
});
Example #5
0
function render(query, callback) {
    var font = helpers.randElt(fonts);
    debug('Yelling ['+query+'] in '+font);
    if (query == 'fontlist') {
        return callback(fonts.length + ' Fonts: '+fonts.join(",\n "));
    } else {
        figlet.text(query, {
            font: font
        }, function (err, data) {
            if (err) {
                console.warn('Figlet error! ' + err + ', ' + data);
                return callback(phrases.say('errors'));
            }
            return callback("```\n" + data + '```');
        });
    }
}
Example #6
0
module.exports = robot => robot.respond(/ascii (.+)/i, res => {
  if (res.match[1]) {
    return figlet.text(res.match[1], 'Standard', (err, data) => {
      if (!err) {
        // To prevent adapters trimming whitespace at the beginning,
        // wrap the ASCII in a code environment.
        switch (robot.adapterName) {
          case 'slack': return res.send(`\`\`\`${data}\`\`\``);
          case 'hipchat': return res.send(`/code ${data}`);
          default: return res.send(`\n${data}`);
        }
      } else {
        return res.send(`Oops, something went wrong! Error: ${err}`);
      }
    });
  } else {
    return res.send("Oh no! You must supply text to convert!");
  }
});
Example #7
0
gulp.task('figlet', [], function (cb) {
  if (figletShown === 0) {
    figlet.text(pkg.name, {
      font: 'Small',
      horizontalLayout: 'default',
      verticalLayout: 'default'
    }, function(err, data) {
      if (err) {
        console.log('Something went wrong with FIGlet');
        console.dir(err);
        return;
      }
      console.log('\n\n');
      console.log(chalk.green(data));
      console.log(chalk.blue(pkg.version));
      console.log('\n\n');
      figletShown = 1;
      cb();
    });
  }
});
import webpack from 'webpack';
import webpackDevMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
import env from 'dotenv';
import chalk from 'chalk';
import figlet from 'figlet';
import reporter from './server/lib/webpackReporter';

import { name } from '../package.json';

env.config();

figlet.text(`Welcome to \n ${process.env.APPLICATION_NAME || name}`, {
  verticalLayout: 'full',
  kerning: 'fitted',
}, (err, data) => {
  if (!err) {
    console.log(chalk.green(data));
  }
});

const app = express();
if (process.env.NODE_ENV === 'development') {
  const config = require('../webpack.config.babel.js').default; // eslint-disable-line
  const compiler = webpack(config);

// Serve hot-reloading bundle to client
  app.use(webpackDevMiddleware(compiler, {
    publicPath: config.output.publicPath,
    reporter,
  }));
  app.use(webpackHotMiddleware(compiler));