Skip to content

Commit

Permalink
Merge branch 'work' into coffee_support
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Olayvar committed Aug 24, 2012
2 parents f1e53ad + 32ca2bf commit c9f8c14
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
Empty file added HISTORY.md
Empty file.
33 changes: 24 additions & 9 deletions lib/bin.coffee
Expand Up @@ -8,7 +8,7 @@
#
path = require 'path'
nomnom = require 'nomnom'
dork = require './index'
resolve = require 'resolve'



Expand Down Expand Up @@ -42,7 +42,7 @@ nomnom.options
# Desc:
# Execute a dork test based on the arguments provided by either
# `process.argv` or the `input` argument.
exports.exec = (input) ->
exec = (input) ->
# Parse the opts, with a possible input override.
opts = nomnom.parse input

Expand All @@ -54,10 +54,25 @@ exports.exec = (input) ->
# All tests within the given file "should" (lol) have defined themselves
# to the dork instance.
require file

# Define any patterns provided.
for pattern in opts.patterns
dork.pattern pattern

# Now run dork.
dork.run()

# Now import the dork session based on the locally installed dork.
# This is done because Dork stores it's sessions in the index module
# of the local dork package. If this bin is installed globally via
# `npm install -g dork` then `require './index'` will return the *wrong
# dork instance*!
# To solve this issue, we use the same dork module that the target file
# should be using when it calls `require 'dork'`.
dirname = path.dirname file
dork = require resolve.sync 'dork', basedir: dirname

# Define any patterns provided.
for pattern in opts.patterns
dork.pattern pattern

# Now run dork.
dork.run()




exports.exec = exec
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -29,8 +29,9 @@
"coffee-script": "1.3.x"
},
"dependencies": {
"emighter": "0.0.1",
"nomnom": "1.5.x",
"emighter": "0.0.1"
"resolve": "0.5.x"
},
"main": "./build/lib/index.js",
"licenses": [
Expand Down

0 comments on commit c9f8c14

Please sign in to comment.