Handle reading and writing in cson.coffee

Moves helpers from fs.coffee to cson.coffee
This commit is contained in:
Kevin Sawicki
2013-03-11 22:39:57 -07:00
parent 832df7149e
commit 115b960ce7
10 changed files with 40 additions and 32 deletions

View File

@@ -1,6 +1,7 @@
fs = require 'fs'
TextMatePackage = require 'text-mate-package'
SnippetBodyParser = require './snippet-body-parser'
CSON = require 'cson'
module.exports =
snippetsLoaded: (snippets) ->
@@ -20,7 +21,7 @@ module.exports =
continue if fs.base(snippetsPath).indexOf('.') is 0
try
if fs.isObjectPath(snippetsPath) and object = fs.readObject(snippetsPath)
if CSON.isObjectPath(snippetsPath) and object = CSON.readObject(snippetsPath)
snippets.push(object)
else if object = fs.readPlist(snippetsPath)
snippets.push(object)
@@ -37,7 +38,7 @@ module.exports =
for snippetsPath in fs.list(snippetsDirPath)
continue if fs.base(snippetsPath).indexOf('.') is 0
try
snippets.push(fs.readObject(snippetsPath))
snippets.push(CSON.readObject(snippetsPath))
catch e
console.warn "Error reading snippets file '#{snippetsPath}'"
@snippetsLoaded(snippets)

View File

@@ -4,6 +4,7 @@ _ = nodeRequire 'underscore'
SnippetExpansion = require './snippet-expansion'
Snippet = require './snippet'
LoadSnippetsTask = require './load-snippets-task'
CSON = require 'cson'
module.exports =
snippetsByExtension: {}
@@ -28,7 +29,7 @@ module.exports =
loadFile: (snippetsPath) ->
try
snippets = fs.readObject(snippetsPath)
snippets = CSON.readObject(snippetsPath)
catch e
console.warn "Error reading snippets file '#{snippetsPath}'"
@add(snippets)