Skip to content

Commit

Permalink
Merge branch 'master' into express
Browse files Browse the repository at this point in the history
Conflicts:
	npm-shrinkwrap.json
  • Loading branch information
winton committed Sep 13, 2012
2 parents 875f8a2 + 03cc79b commit 5491a29
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 138 deletions.
66 changes: 39 additions & 27 deletions bin/node-template.coffee
@@ -1,9 +1,10 @@
{ exec } = require "child_process"
path = require "path"
fs = require "fs"
path = require "path"

require "colors"
glob = require "glob"
_ = require "underscore"
colors = require "colors"
glob = require "glob"
_ = require "underscore"

module.exports = class Bin
constructor: (options={}) ->
Expand Down Expand Up @@ -63,32 +64,13 @@ module.exports = class Bin
"rm test/node-template.coffee"
]

# Overwrite files to remove node-template code

@overwrite =
"bin/node-template": """
#!/usr/bin/env node
require("../lib/#{name}");
"""
"src/node-template.coffee": """
common = require './#{name}/common'
async = common.async
_ = common.underscore
"""

_.each @overwrite, (body, path) ->
body = body.replace(/\n/g, "\\n").replace(/"/g, "\\\"")
commands.push "echo \"#{body}\" > #{path}"

@executing(commands)

exec commands.join(' && '), @catchError =>

dir = if dir then "#{dir}/" else ""
cwd = process.cwd()

dir = if dir then "#{dir}/" else ""
commands = []
cwd = process.cwd()

glob "#{dir}#{name}/**/node-template*", (e, paths) =>
_.each paths, (path) ->
Expand All @@ -97,12 +79,42 @@ module.exports = class Bin
@executing(commands)

exec commands.join(' && '), @catchError =>
commands = [
"cd #{dir}#{name}"

commands = [ "cd #{dir}#{name}" ]

# Overwrite files to remove node-template code

overwrite = {}

overwrite["bin/#{name}"] =
"""
#!/usr/bin/env node
require("../lib/#{name}");
"""

overwrite["src/#{name}.coffee"] =
"""
common = require './#{name}/common'
async = common.async
_ = common.underscore
"""

_.each overwrite, (body, path) ->
if fs.existsSync("#{dir}#{name}/#{path}")
body = body.replace(/\n/g, "\\n").replace(/"/g, "\\\"")
commands.push "echo \"#{body}\" > #{path}"

if fs.existsSync("#{dir}#{name}/src")
commands.push("coffee -o lib -c src")

commands = commands.concat [
"cake install"
"cd #{cwd}"
]

@executing(commands)

exec commands.join(' && '), ->
if options.done then options.done() else process.exit()

Expand Down
120 changes: 9 additions & 111 deletions npm-shrinkwrap.json

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

0 comments on commit 5491a29

Please sign in to comment.