Permalink
Browse files

Use lib/ instead of js/ ; update Ark interface to make it more conven…

…ient for programmatic use
  • Loading branch information...
1 parent 5453560 commit b6cf99111725fdbc5dfc327c5a669e74a3fbc282 @dyoder dyoder committed Mar 6, 2013
View
@@ -6,5 +6,5 @@ task :docs do
end
task :build do
- `coffee -c -o js src`
+ `coffee -c -o lib src`
end
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
File renamed without changes.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
File renamed without changes.
File renamed without changes.
View
@@ -17,8 +17,6 @@ Util = require "util"
inspect = (thing) -> Util.inspect(thing)
-print = console.log
-
error = (message) -> throw new Error(message)
warn = (message) -> process.stderr.write "#{message}\n"
@@ -27,15 +25,6 @@ read = (path) -> FileSystem.readFileSync(path,'utf-8')
readdir = (path) -> FileSystem.readdirSync(path)
-readStream = (stream) ->
- buffer = ""
- fiber = Fiber.current
- stream.resume()
- stream.on "data", (data) -> buffer += data
- stream.on "end", -> fiber.run()
- Fiber.yield()
- buffer
-
stat = (path) -> FileSystem.statSync(path)
Crypto = require "crypto"
@@ -360,22 +349,19 @@ Ark =
error "Please provide source directory via --source option" unless options.source?
# Generate the manifest from the options, format it, and send it to standard out.
- print JSON.stringify(manifest(options), null, 2)
+ JSON.stringify(manifest(options), null, 2)
package: (options) ->
# We can get the manifest via an option or we can generate one.
- manifest = if options.manifest?
- JSON.parse readStream options.manifest
- else
- manifest options
+ options.manifest ?= manifest options
# We process the JavaScript via the `index` function and then, based on the options
# either minify it or beautify it.
- print if options.minify
- minify code index manifest
+ if options.minify
+ minify code index options.manifest
else
- beautify code index manifest
+ beautify code index options.manifest
# We wrap the subcommand functions in fibers so we can use fibers within the
# implementation.
View
@@ -4,9 +4,20 @@
FileSystem = require "fs"
-# Convenience method for readability ...
+# Convenience methods for readability ...
read = (path) -> FileSystem.readFileSync(path,'utf-8')
+readStream = (stream) ->
+ buffer = ""
+ fiber = Fiber.current
+ stream.resume()
+ stream.on "data", (data) -> buffer += data
+ stream.on "end", -> fiber.run()
+ Fiber.yield()
+ buffer
+
+print = console.log
+
# Module constant for printing the usage.
usage = read("#{__dirname}/../doc/USAGE")
@@ -71,7 +82,7 @@ options =
# Ff a source directory is specified, use that; otherwise assume we'll read
# the manifest from stdin.
-options.manifest = process.stdin unless options.source?
+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
@@ -80,6 +91,6 @@ options.extensions ?= "js,json,coffee"
# Run the subcommand using the options given.
try
- Ark[command](options)
+ print Ark[command](options)
catch e
error(e.message)

0 comments on commit b6cf991

Please sign in to comment.