-
Notifications
You must be signed in to change notification settings - Fork 69
Dev Utility to Open Settings.cson of All Locales
Te-Chi Liu edited this page Mar 23, 2017
·
15 revisions
It's a tiny util script to save time for translators or developers
# 1. rename projRoot to your path
# 2. copy following to your init.config
atom.commands.add 'atom-workspace', 'i18n-dev:open-all-settings-cson', ->
return unless atom.workspace.getActivePane()
path = require('path')
fs = require('fs')
projRoot = '/PATH/TO/ATOM-I18N' # NOTE enter your path
locales = fs.readdirSync(path.join(projRoot, 'def'))
fileName = 'settings.cson'
csons = locales.map((locale) => path.join(projRoot, 'def', locale, fileName))
# open files in sequential order
csons.reduce((cur, nextCson) =>
cur.then(() => atom.workspace.open(nextCson))
, Promise.resolve('start'))
Review:
-
atom.workspace.open(path)
always returns one resolved promise even path is bad (atom handles that for you) so we don't needcatch()
at the end of promise chain - you can customize
fileName
to extend this script - a good chance to practice combining
Promise
and array methodsreduce()
: ]