Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing project set up with branch specified

  • Loading branch information...
commit 03cc79b0b87be65103bae850874a8818f6ec8214 1 parent ad24459
@winton authored
Showing with 53 additions and 46 deletions.
  1. +39 −32 bin/node-template.coffee
  2. +14 −14 npm-shrinkwrap.json
View
71 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={}) ->
@@ -63,51 +64,57 @@ 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) ->
commands.push "mv #{path} #{Bin.renamePath(path, name)}"
- commands = commands.concat [
- "cd #{dir}#{name}"
- "coffee -o lib -c src"
- ]
-
@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()
View
28 npm-shrinkwrap.json
@@ -1,6 +1,6 @@
{
"name": "node-template",
- "version": "0.1.4",
+ "version": "0.1.5",
"dependencies": {
"async": {
"version": "0.1.22"
@@ -36,19 +36,6 @@
"coffee-script": {
"version": "1.3.3"
},
- "sinon": {
- "version": "1.4.2",
- "dependencies": {
- "buster-format": {
- "version": "0.5.5",
- "dependencies": {
- "buster-core": {
- "version": "0.6.4"
- }
- }
- }
- }
- },
"mocha": {
"version": "1.4.2",
"dependencies": {
@@ -76,6 +63,19 @@
"version": "0.3.3"
}
}
+ },
+ "sinon": {
+ "version": "1.4.2",
+ "dependencies": {
+ "buster-format": {
+ "version": "0.5.5",
+ "dependencies": {
+ "buster-core": {
+ "version": "0.6.4"
+ }
+ }
+ }
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.