#!/usr/bin/env node /*! * peanut * Copyright(c) 2011 Didit * MIT Licensed */ /** * Module dependencies. */ var steps = require('../lib/steps'); var fs = require('fs'); var _ = require('underscore')._; var nomnom = require('nomnom'); /** * Command line options. */ global.__peanut__ = {}; __peanut__.options = nomnom.scriptName('peanut').opts({ path: { help: "Your features path (default: features)", default: ["features"], position: 0, list: true }, step_definition_path: { help: "Your step definitions path (default: features)", default: ["features"], abbr: "s", position: 1, list: true }, output: { help: "Specify a file to output JUnit compatible xml", abbr: "o", metavar: "OUTPUT", default: null }, tag: { help: "Run tag", abbr: "t", metavar: "TAG" }, timeout: { help: "Test timeout in ms (default: 5000)", metavar: "TIME", default: 5000 } }).parseArgs(); /** * Step definitions. */ ['Given', 'When', 'Then'].forEach(function(step) { global[step] = steps[step]; }); __peanut__.stepDefinitions = []; __peanut__.features = {} /** * Custom error handler. */ require('../lib/errors'); /** * support/env.js check. */ __peanut__.envExists = true; try { var path = process.cwd() + '/' + __peanut__.options.path[0]; var env = '/support/env.js'; fs.statSync(path + env); __peanut__.envPath = path + env; } catch(err) { try { path = process.cwd() + '/' + __peanut__.options.path[0].split("/")[0]; fs.statSync(path + env); __peanut__.envPath = path + env; } catch(err) { __peanut__.envExists = false; } } /** * Formatter. */ __peanut__.formatter = require('../lib/formatters/cli'); /** * Runner. */ require('../lib/runner/cli');