Replace ## in package-generator templates with __

This is a workaround for
<http://code.google.com/p/gyp/issues/detail?id=323>.

A future change will cause gyp to generate Makefiles to compile
.coffee/.cson files to .js/.json. Makefiles use # as the comment
character, and gyp isn't smart enough to escape the #. So now we don't
use # in filenames to work around this bug.
This commit is contained in:
Adam Roben
2013-03-04 11:21:29 -05:00
parent c96e9acb64
commit 6511d0e111
12 changed files with 50 additions and 50 deletions

View File

@@ -73,7 +73,7 @@ class PackageGeneratorView extends View
fs.write(sourcePath, content)
replacePackageNamePlaceholders: (string, packageName) ->
placeholderRegex = /##(?:(package-name)|([pP]ackageName)|(package_name))##/g
placeholderRegex = /__(?:(package-name)|([pP]ackageName)|(package_name))__/g
string = string.replace placeholderRegex, (match, dash, camel, underscore) ->
if dash
_.dasherize(packageName)

View File

@@ -1,3 +1,3 @@
# DOCUMENT: link to keymap documentation
'body':
'meta-alt-ctrl-o': '##package-name##:toggle'
'meta-alt-ctrl-o': '__package-name__:toggle'

View File

@@ -1,13 +0,0 @@
##PackageName##View = require '##package-name##/lib/##package-name##-view'
module.exports =
##packageName##View: null
activate: (state) ->
@##packageName##View = new ##PackageName##View(state.##packageName##ViewState)
deactivate: ->
@##packageName##View.destroy()
serialize: ->
##packageName##ViewState: @##packageName##View.serialize()

View File

@@ -1,13 +1,13 @@
{$$, View} = require 'space-pen'
module.exports =
class ##PackageName##View extends View
class __PackageName__View extends View
@content: ->
@div class: '##package-name## overlay from-top', =>
@div "The ##PackageName## package is Alive! It's ALIVE!", class: "message"
@div class: '__package-name__ overlay from-top', =>
@div "The __PackageName__ package is Alive! It's ALIVE!", class: "message"
initialize: (serializeState) ->
rootView.command "##package-name##:toggle", => @toggle()
rootView.command "__package-name__:toggle", => @toggle()
# Returns an object that can be retrieved when package is activated
serialize: ->
@@ -17,7 +17,7 @@ class ##PackageName##View extends View
@detach()
toggle: ->
console.log "##PackageName##View was toggled!"
console.log "__PackageName__View was toggled!"
if @hasParent()
@detach()
else

View File

@@ -0,0 +1,13 @@
__PackageName__View = require '__package-name__/lib/__package-name__-view'
module.exports =
__packageName__View: null
activate: (state) ->
@__packageName__View = new __PackageName__View(state.__packageName__ViewState)
deactivate: ->
@__packageName__View.destroy()
serialize: ->
__packageName__ViewState: @__packageName__View.serialize()

View File

@@ -1,2 +1,2 @@
'main': 'lib/##package-name##'
'activationEvents': ['##package-name##:toggle']
'main': 'lib/__package-name__'
'activationEvents': ['__package-name__:toggle']

View File

@@ -1,5 +0,0 @@
##PackageName## = require '##package-name##/lib/##package-name##'
describe "##PackageName##", ->
it "has one valid test", ->
expect("life").toBe "easy"

View File

@@ -1,21 +0,0 @@
##PackageName##View = require '##package-name##/lib/##package-name##-view'
RootView = require 'root-view'
# This spec is focused because it starts with an `f`. Remove the `f`
# to unfocus the spec.
#
# Press meta-alt-ctrl-s to run the specs
fdescribe "##PackageName##View", ->
##packageName## = null
beforeEach ->
window.rootView = new RootView
##packageName## = window.loadPackage('##packageName##', activateImmediately: true)
describe "when the ##package-name##:toggle event is triggered", ->
it "attaches and then detaches the view", ->
expect(rootView.find('.##package-name##')).not.toExist()
rootView.trigger '##package-name##:toggle'
expect(rootView.find('.##package-name##')).toExist()
rootView.trigger '##package-name##:toggle'
expect(rootView.find('.##package-name##')).not.toExist()

View File

@@ -0,0 +1,5 @@
__PackageName__ = require '__package-name__/lib/__package-name__'
describe "__PackageName__", ->
it "has one valid test", ->
expect("life").toBe "easy"

View File

@@ -0,0 +1,21 @@
__PackageName__View = require '__package-name__/lib/__package-name__-view'
RootView = require 'root-view'
# This spec is focused because it starts with an `f`. Remove the `f`
# to unfocus the spec.
#
# Press meta-alt-ctrl-s to run the specs
fdescribe "__PackageName__View", ->
__packageName__ = null
beforeEach ->
window.rootView = new RootView
__packageName__ = window.loadPackage('__packageName__', activateImmediately: true)
describe "when the __package-name__:toggle event is triggered", ->
it "attaches and then detaches the view", ->
expect(rootView.find('.__package-name__')).not.toExist()
rootView.trigger '__package-name__:toggle'
expect(rootView.find('.__package-name__')).toExist()
rootView.trigger '__package-name__:toggle'
expect(rootView.find('.__package-name__')).not.toExist()

View File

@@ -1,2 +0,0 @@
.##package-name## {
}

View File

@@ -0,0 +1,2 @@
.__package-name__ {
}