Skip to content

Commit

Permalink
CLI wasn't wired up correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
dyoder committed Mar 9, 2013
1 parent 04b5f2d commit 56794c2
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 37 deletions.
2 changes: 1 addition & 1 deletion bin/ark
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env node

require("../js/cli")
require("../lib/cli")
4 changes: 0 additions & 4 deletions lib/ark.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 29 additions & 14 deletions lib/cli.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ark",
"version": "0.3.0",
"version": "0.3.1",
"description": "Packages code for the browser as Node modules.",
"main": "lib/ark.js",
"bin": {
Expand Down
5 changes: 0 additions & 5 deletions src/ark.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,4 @@ Ark =
else
beautify code index options.manifest

# We wrap the subcommand functions in fibers so we can use fibers within the
# implementation.
Ark.manifest = run_as_fiber Ark.manifest
Ark.package = run_as_fiber Ark.package

module.exports = Ark
40 changes: 28 additions & 12 deletions src/cli.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ usage = read("#{__dirname}/../doc/USAGE")
# Optimist gives us a simple interface for handling CLI arguments.
Optimist = require "optimist"

# We use fibers to make `glob` synchronous - see below.
Fibers = require "fibers"
Future = require "fibers/future"

# Take any function and run it as a fiber.
run_as_fiber = (fn) ->
->
_arguments = arguments
Fiber( -> fn(_arguments...) ).run()



# ## Local Modules

# The subcommands are actually implemented in the [ark][] source file.
Expand Down Expand Up @@ -80,17 +92,21 @@ options =
minify: argv.m or argv.minify
extensions: argv.x or argv.extensions

# Ff a source directory is specified, use that; otherwise assume we'll read
# the manifest from stdin.
options.manifest = (JSON.parse readStream process.stdin) unless options.source?

# By default, we handle JavaScript, JSON, and CoffeeScript files. Presently,
# this only affects the `manifest` subcommand when you're not using the
# `--static` option.
options.extensions ?= "js,json,coffee"
(Fiber ->

# Ff a source directory is specified, use that; otherwise assume we'll read
# the manifest from stdin.
options.manifest = (JSON.parse readStream process.stdin) unless options.source?

# By default, we handle JavaScript, JSON, and CoffeeScript files. Presently,
# this only affects the `manifest` subcommand when you're not using the
# `--static` option.
options.extensions ?= "js,json,coffee"

# Run the subcommand using the options given.
try
print Ark[command](options)
catch e
error(e.message)
# Run the subcommand using the options given.
try
print Ark[command](options)
catch e
error(e.message)
).run()

0 comments on commit 56794c2

Please sign in to comment.