mirror of
https://github.com/atom/atom.git
synced 2026-02-07 05:05:02 -05:00
Handle reading and writing in cson.coffee
Moves helpers from fs.coffee to cson.coffee
This commit is contained in:
@@ -2,6 +2,7 @@ Package = require 'package'
|
||||
fs = require 'fs'
|
||||
_ = nodeRequire 'underscore'
|
||||
$ = require 'jquery'
|
||||
CSON = require 'cson'
|
||||
|
||||
module.exports =
|
||||
class AtomPackage extends Package
|
||||
@@ -69,7 +70,7 @@ class AtomPackage extends Package
|
||||
|
||||
loadMetadata: ->
|
||||
if metadataPath = fs.resolveExtension(fs.join(@path, 'package'), ['cson', 'json'])
|
||||
@metadata = fs.readObject(metadataPath)
|
||||
@metadata = CSON.readObject(metadataPath)
|
||||
@metadata ?= {}
|
||||
|
||||
loadKeymaps: ->
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
fs = require 'fs'
|
||||
Theme = require 'theme'
|
||||
CSON = require 'cson'
|
||||
|
||||
module.exports =
|
||||
class AtomTheme extends Theme
|
||||
@@ -13,7 +14,7 @@ class AtomTheme extends Theme
|
||||
else
|
||||
metadataPath = fs.resolveExtension(fs.join(@path, 'package'), ['cson', 'json'])
|
||||
if fs.isFile(metadataPath)
|
||||
stylesheetNames = fs.readObject(metadataPath)?.stylesheets
|
||||
stylesheetNames = CSON.readObject(metadataPath)?.stylesheets
|
||||
if stylesheetNames
|
||||
@loadStylesheet(fs.join(@path, name)) for name in stylesheetNames
|
||||
else
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
fs = require 'fs'
|
||||
_ = nodeRequire 'underscore'
|
||||
EventEmitter = require 'event-emitter'
|
||||
CSON = require 'cson'
|
||||
|
||||
configDirPath = fs.absolute("~/.atom")
|
||||
bundledPackagesDirPath = fs.join(resourcePath, "src/packages")
|
||||
@@ -55,7 +56,7 @@ class Config
|
||||
|
||||
loadUserConfig: ->
|
||||
if fs.exists(@configFilePath)
|
||||
userConfig = fs.readObject(@configFilePath)
|
||||
userConfig = CSON.readObject(@configFilePath)
|
||||
_.extend(@settings, userConfig)
|
||||
|
||||
get: (keyPath) ->
|
||||
@@ -96,6 +97,6 @@ class Config
|
||||
@trigger 'updated'
|
||||
|
||||
save: ->
|
||||
fs.writeObject(@configFilePath, @settings)
|
||||
CSON.writeObject(@configFilePath, @settings)
|
||||
|
||||
_.extend Config.prototype, EventEmitter
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
$ = require 'jquery'
|
||||
_ = nodeRequire 'underscore'
|
||||
fs = require 'fs'
|
||||
CSON = require 'cson'
|
||||
|
||||
BindingSet = require 'binding-set'
|
||||
|
||||
@@ -39,7 +40,7 @@ class Keymap
|
||||
@load(filePath) for filePath in fs.list(directoryPath, ['.cson', '.json'])
|
||||
|
||||
load: (path) ->
|
||||
@add(fs.readObject(path))
|
||||
@add(CSON.readObject(path))
|
||||
|
||||
add: (keymap) ->
|
||||
for selector, bindings of keymap
|
||||
|
||||
@@ -2,14 +2,15 @@ _ = nodeRequire 'underscore'
|
||||
fs = require 'fs'
|
||||
plist = require 'plist'
|
||||
Token = require 'token'
|
||||
CSON = require 'cson'
|
||||
{OnigRegExp, OnigScanner} = nodeRequire 'oniguruma'
|
||||
|
||||
module.exports =
|
||||
class TextMateGrammar
|
||||
@readFromPath: (path) ->
|
||||
grammarContent = null
|
||||
if fs.isObjectPath(path)
|
||||
grammarContent = fs.readObject(path)
|
||||
if CSON.isObjectPath(path)
|
||||
grammarContent = CSON.readObject(path)
|
||||
else
|
||||
plist.parseString fs.read(path), (e, data) ->
|
||||
throw new Error(e) if e
|
||||
|
||||
@@ -3,6 +3,7 @@ fs = require 'fs'
|
||||
plist = require 'plist'
|
||||
_ = nodeRequire 'underscore'
|
||||
TextMateGrammar = require 'text-mate-grammar'
|
||||
CSON = require 'cson'
|
||||
|
||||
module.exports =
|
||||
class TextMatePackage extends Package
|
||||
@@ -76,8 +77,8 @@ class TextMatePackage extends Package
|
||||
readObjectFromPath: (path, callback) ->
|
||||
object = null
|
||||
error = null
|
||||
if fs.isObjectPath(path)
|
||||
object = fs.readObject(path)
|
||||
if CSON.isObjectPath(path)
|
||||
object = CSON.readObject(path)
|
||||
else
|
||||
plist.parseString fs.read(path), (e, data) ->
|
||||
error = e
|
||||
|
||||
Reference in New Issue
Block a user