fix(keymaps): JSON => CSON during cibuild final phase

This commit is contained in:
Ben Gotow 2015-08-18 14:50:53 -07:00
parent 9a87392617
commit 5b0c82abb1
7 changed files with 15 additions and 9 deletions

View file

@ -146,7 +146,7 @@ module.exports = (grunt) ->
csonConfig =
options:
rootObject: true
rootObject: false
cachePath: path.join(home, '.nylas', 'compile-cache', 'grunt-cson')
glob_to_multiple:
@ -154,6 +154,7 @@ module.exports = (grunt) ->
src: [
'menus/*.cson'
'keymaps/*.cson'
'keymaps/templates/*.cson'
'static/**/*.cson'
]
dest: appDir

View file

@ -36,7 +36,9 @@ class PreferencesKeymaps extends React.Component
fs.readdir templatesDir, (err, files) =>
return unless files and files instanceof Array
templates = files.filter (filename) =>
path.extname(filename) is '.cson'
path.extname(filename) is '.cson' or path.extname(filename) is '.json'
templates = templates.map (filename) =>
path.parse(filename).name
@setState(templates: templates)
_getStateFromKeymaps: =>
@ -55,7 +57,7 @@ class PreferencesKeymaps extends React.Component
value={@props.config.get('core.keymapTemplate')}
onChange={ (event) => @props.config.set('core.keymapTemplate', event.target.value) }>
{ @state.templates.map (template) =>
<option key={template} value={template}>{path.basename(template, '.cson')}</option>
<option key={template} value={template}>{template}</option>
}
</select>
</div>

View file

@ -22,7 +22,7 @@ module.exports =
type: 'string'
keymapTemplate:
type: 'string'
default: 'Gmail.cson'
default: 'Gmail'
attachments:
type: 'object'
properties:

View file

@ -10,8 +10,8 @@ KeymapManager::onDidLoadBundledKeymaps = (callback) ->
KeymapManager::loadBundledKeymaps = ->
# Load the base keymap and the base.platform keymap
baseKeymap = path.join(@resourcePath, 'keymaps', 'base.cson')
basePlatformKeymap = path.join(@resourcePath, 'keymaps', "base.#{process.platform}.cson")
baseKeymap = fs.resolve(path.join(@resourcePath, 'keymaps'), 'base', ['cson', 'json'])
basePlatformKeymap = fs.resolve(path.join(@resourcePath, 'keymaps'), "base-#{process.platform}", ['cson', 'json'])
@loadKeymap(baseKeymap)
@loadKeymap(basePlatformKeymap)
@ -22,9 +22,12 @@ KeymapManager::loadBundledKeymaps = ->
@removeBindingsFromSource(templateKeymapPath) if templateKeymapPath
templateFile = atom.config.get(templateConfigKey)
if templateFile
templateKeymapPath = path.join(@resourcePath, 'keymaps', 'templates', templateFile)
@loadKeymap(templateKeymapPath)
@emitter.emit('did-reload-keymap', {path: templateKeymapPath})
templateKeymapPath = fs.resolve(path.join(@resourcePath, 'keymaps', 'templates'), templateFile, ['cson', 'json'])
if fs.existsSync(templateKeymapPath)
@loadKeymap(templateKeymapPath)
@emitter.emit('did-reload-keymap', {path: templateKeymapPath})
else
console.warn("Could not find #{templateKeymapPath}")
atom.config.observe(templateConfigKey, reloadTemplateKeymap)
reloadTemplateKeymap()