Show Atom's version.

This commit is contained in:
Cheng Zhao
2013-05-24 23:24:46 +08:00
parent 22d77af409
commit a00fe91fca
4 changed files with 30 additions and 1 deletions

View File

@@ -1,4 +1,7 @@
{
'variables': {
'version%': "<!(git rev-parse --short HEAD)",
},
'includes': [
'sources.gypi',
],
@@ -76,6 +79,22 @@
],
},
],
'actions': [
{
'action_name': 'generate_version',
'inputs': [
'script/generate-version',
],
'outputs': [
'<(PRODUCT_DIR)/Atom.app/Contents/Resources/version'
],
'action': [
'script/generate-version',
'<(version)',
'<(PRODUCT_DIR)/Atom.app/Contents/Resources/version'
]
},
],
'postbuilds': [
{
'postbuild_name': 'Copy Static Files',

3
script/generate-version Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
echo -n $1 > $2

View File

@@ -262,4 +262,4 @@ window.atom =
console.error "Failed to load `#{userInitScriptPath}`", error.stack, error
getVersion: ->
@sendMessageToBrowserProcess('getVersion')
ipc.sendChannelSync 'get-version'

View File

@@ -13,6 +13,9 @@ testMode = false
getHomeDir = ->
process.env[if process.platform is 'win32' then 'USERPROFILE' else 'HOME']
getVersion = ->
String fs.readFileSync(path.join(__dirname, '..', '..', 'version'))
setupNodePath = ->
resourcePaths = [
'src/stdlib',
@@ -120,6 +123,7 @@ class AtomApplication
label: 'Atom'
submenu: [
{ label: 'About Atom', selector: 'orderFrontStandardAboutPanel:' }
{ label: "Version #{getVersion()}", enabled: false }
{ type: 'separator' }
{ label: 'Preferences...', accelerator: 'Command+,', click: => @openConfig() }
{ type: 'separator' }
@@ -184,6 +188,9 @@ class AtomApplication
ipc.on 'new-window', =>
@open()
ipc.on 'get-version', (event) ->
event.result = getVersion()
sendCommand: (command) ->
atomWindow.sendCommand command for atomWindow in @windows when atomWindow.browserWindow.isFocused()