mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Update fs-utils references to fs-plus
This commit is contained in:
@@ -291,9 +291,9 @@ class AtomApplication
|
||||
openUrl: ({urlToOpen, devMode}) ->
|
||||
unless @packages?
|
||||
PackageManager = require '../package-manager'
|
||||
fsUtils = require '../fs-utils'
|
||||
fs = require 'fs-plus'
|
||||
@packages = new PackageManager
|
||||
configDirPath: fsUtils.absolute('~/.atom')
|
||||
configDirPath: fs.absolute('~/.atom')
|
||||
devMode: devMode
|
||||
resourcePath: @resourcePath
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ class File
|
||||
promise = deferred.promise
|
||||
content = []
|
||||
bytesRead = 0
|
||||
readStream = fsUtils.createReadStream @getPath(), encoding: 'utf8'
|
||||
readStream = fs.createReadStream @getPath(), encoding: 'utf8'
|
||||
readStream.on 'data', (chunk) ->
|
||||
content.push(chunk)
|
||||
bytesRead += chunk.length
|
||||
@@ -110,7 +110,7 @@ class File
|
||||
|
||||
# Public: Returns whether the file exists.
|
||||
exists: ->
|
||||
fsUtils.exists(@getPath())
|
||||
fs.exists(@getPath())
|
||||
|
||||
setDigest: (contents) ->
|
||||
@digest = crypto.createHash('sha1').update(contents ? '').digest('hex')
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
fs = require 'fs'
|
||||
ipc = require 'ipc'
|
||||
path = require 'path'
|
||||
Q = require 'q'
|
||||
{$, $$, View} = require './space-pen-extensions'
|
||||
fsUtils = require './fs-utils'
|
||||
_ = require 'underscore-plus'
|
||||
fs = require 'fs-plus'
|
||||
telepath = require 'telepath'
|
||||
Editor = require './editor'
|
||||
Pane = require './pane'
|
||||
@@ -181,7 +180,7 @@ class RootView extends View
|
||||
promise = project.open(filePath, {initialLine}) if not editSession
|
||||
|
||||
fileSize = 0
|
||||
fileSize = fs.statSync(filePath).size if fsUtils.exists(filePath)
|
||||
fileSize = fs.statSync(filePath).size if fs.exists(filePath)
|
||||
|
||||
Q(editSession ? promise).then (editSession) =>
|
||||
if not activePane
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
_ = require 'underscore-plus'
|
||||
{specificity} = require 'clear-cut'
|
||||
{$, $$} = require './space-pen-extensions'
|
||||
fsUtils = require './fs-utils'
|
||||
{Emitter} = require 'emissary'
|
||||
NullGrammar = require './null-grammar'
|
||||
TextMateScopeSelector = require('first-mate').ScopeSelector
|
||||
|
||||
@@ -6,7 +6,6 @@ Q = require 'q'
|
||||
telepath = require 'telepath'
|
||||
|
||||
_ = require 'underscore-plus'
|
||||
fsUtils = require './fs-utils'
|
||||
File = require './file'
|
||||
|
||||
{Point, Range} = telepath
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
_ = require 'underscore-plus'
|
||||
fsUtils = require './fs-utils'
|
||||
fs = require 'fs-plus'
|
||||
plist = require 'plist'
|
||||
Token = require './token'
|
||||
{OnigRegExp, OnigScanner} = require 'oniguruma'
|
||||
@@ -16,14 +16,14 @@ class TextMateGrammar
|
||||
Emitter.includeInto(this)
|
||||
|
||||
@load: (grammarPath, done) ->
|
||||
fsUtils.readObject grammarPath, (error, object) ->
|
||||
fs.readObject grammarPath, (error, object) ->
|
||||
if error?
|
||||
done(error)
|
||||
else
|
||||
done(null, new TextMateGrammar(object))
|
||||
|
||||
@loadSync: (grammarPath) ->
|
||||
new TextMateGrammar(fsUtils.readObjectSync(grammarPath))
|
||||
new TextMateGrammar(fs.readObjectSync(grammarPath))
|
||||
|
||||
name: null
|
||||
rawPatterns: null
|
||||
@@ -74,7 +74,7 @@ class TextMateGrammar
|
||||
true
|
||||
|
||||
getScore: (filePath, contents) ->
|
||||
contents = fsUtils.read(filePath) if not contents? and fsUtils.isFileSync(filePath)
|
||||
contents = fs.read(filePath) if not contents? and fs.isFileSync(filePath)
|
||||
|
||||
if syntax.grammarOverrideForPath(filePath) is @scopeName
|
||||
2 + (filePath?.length ? 0)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Package = require './package'
|
||||
fsUtils = require './fs-utils'
|
||||
path = require 'path'
|
||||
_ = require 'underscore-plus'
|
||||
fs = require 'fs-plus'
|
||||
TextMateGrammar = require './text-mate-grammar'
|
||||
async = require 'async'
|
||||
|
||||
@@ -54,9 +54,9 @@ class TextMatePackage extends Package
|
||||
legalGrammarExtensions: ['plist', 'tmLanguage', 'tmlanguage', 'json', 'cson']
|
||||
|
||||
loadGrammars: (done) ->
|
||||
fsUtils.isDirectory @getSyntaxesPath(), (isDirectory) =>
|
||||
fs.isDirectory @getSyntaxesPath(), (isDirectory) =>
|
||||
if isDirectory
|
||||
fsUtils.list @getSyntaxesPath(), @legalGrammarExtensions, (error, paths) =>
|
||||
fs.list @getSyntaxesPath(), @legalGrammarExtensions, (error, paths) =>
|
||||
if error?
|
||||
console.log("Error loading grammars of TextMate package '#{@path}':", error.stack, error)
|
||||
done()
|
||||
@@ -72,7 +72,7 @@ class TextMatePackage extends Package
|
||||
done()
|
||||
|
||||
loadGrammarsSync: ->
|
||||
for grammarPath in fsUtils.listSync(@getSyntaxesPath(), @legalGrammarExtensions)
|
||||
for grammarPath in fs.listSync(@getSyntaxesPath(), @legalGrammarExtensions)
|
||||
@addGrammar(TextMateGrammar.loadSync(grammarPath))
|
||||
|
||||
addGrammar: (grammar) ->
|
||||
@@ -83,14 +83,14 @@ class TextMatePackage extends Package
|
||||
|
||||
getSyntaxesPath: ->
|
||||
syntaxesPath = path.join(@path, "syntaxes")
|
||||
if fsUtils.isDirectorySync(syntaxesPath)
|
||||
if fs.isDirectorySync(syntaxesPath)
|
||||
syntaxesPath
|
||||
else
|
||||
path.join(@path, "Syntaxes")
|
||||
|
||||
getPreferencesPath: ->
|
||||
preferencesPath = path.join(@path, "preferences")
|
||||
if fsUtils.isDirectorySync(preferencesPath)
|
||||
if fs.isDirectorySync(preferencesPath)
|
||||
preferencesPath
|
||||
else
|
||||
path.join(@path, "Preferences")
|
||||
@@ -101,8 +101,8 @@ class TextMatePackage extends Package
|
||||
selector = syntax.cssSelectorFromScopeSelector(grammar.scopeName)
|
||||
@scopedProperties.push({selector, properties})
|
||||
|
||||
for preferencePath in fsUtils.listSync(@getPreferencesPath())
|
||||
{scope, settings} = fsUtils.readObjectSync(preferencePath)
|
||||
for preferencePath in fs.listSync(@getPreferencesPath())
|
||||
{scope, settings} = fs.readObjectSync(preferencePath)
|
||||
if properties = @propertiesFromTextMateSettings(settings)
|
||||
selector = syntax.cssSelectorFromScopeSelector(scope) if scope?
|
||||
@scopedProperties.push({selector, properties})
|
||||
@@ -134,17 +134,17 @@ class TextMatePackage extends Package
|
||||
@loadTextMatePreferenceObjects(preferenceObjects, done)
|
||||
|
||||
loadTextMatePreferenceObjects: (preferenceObjects, done) ->
|
||||
fsUtils.isDirectory @getPreferencesPath(), (isDirectory) =>
|
||||
fs.isDirectory @getPreferencesPath(), (isDirectory) =>
|
||||
return done() unless isDirectory
|
||||
|
||||
fsUtils.list @getPreferencesPath(), (error, paths) =>
|
||||
fs.list @getPreferencesPath(), (error, paths) =>
|
||||
if error?
|
||||
console.log("Error loading preferences of TextMate package '#{@path}':", error.stack, error)
|
||||
done()
|
||||
return
|
||||
|
||||
loadPreferencesAtPath = (preferencePath, done) ->
|
||||
fsUtils.readObject preferencePath, (error, preferences) =>
|
||||
fs.readObject preferencePath, (error, preferences) =>
|
||||
if error?
|
||||
console.warn("Failed to parse preference at path '#{preferencePath}'", error.stack, error)
|
||||
else
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
path = require 'path'
|
||||
{Emitter} = require 'emissary'
|
||||
Package = require './package'
|
||||
AtomPackage = require './atom-package'
|
||||
|
||||
_ = require 'underscore-plus'
|
||||
{Emitter} = require 'emissary'
|
||||
fs = require 'fs-plus'
|
||||
|
||||
Package = require './package'
|
||||
AtomPackage = require './atom-package'
|
||||
{$} = require './space-pen-extensions'
|
||||
fsUtils = require './fs-utils'
|
||||
|
||||
|
||||
# Private: Handles discovering and loading available themes.
|
||||
###
|
||||
@@ -81,12 +83,12 @@ class ThemeManager
|
||||
if themePath = @packageManager.resolvePackagePath(themeName)
|
||||
themePaths.push(path.join(themePath, AtomPackage.stylesheetsDir))
|
||||
|
||||
themePath for themePath in themePaths when fsUtils.isDirectorySync(themePath)
|
||||
themePath for themePath in themePaths when fs.isDirectorySync(themePath)
|
||||
|
||||
# Public:
|
||||
getUserStylesheetPath: ->
|
||||
stylesheetPath = fsUtils.resolve(path.join(atom.config.configDirPath, 'user'), ['css', 'less'])
|
||||
if fsUtils.isFileSync(stylesheetPath)
|
||||
stylesheetPath = fs.resolve(path.join(atom.config.configDirPath, 'user'), ['css', 'less'])
|
||||
if fs.isFileSync(stylesheetPath)
|
||||
stylesheetPath
|
||||
else
|
||||
null
|
||||
@@ -106,7 +108,7 @@ class ThemeManager
|
||||
# Internal-only:
|
||||
reloadBaseStylesheets: ->
|
||||
@requireStylesheet('../static/atom')
|
||||
if nativeStylesheetPath = fsUtils.resolveOnLoadPath(process.platform, ['css', 'less'])
|
||||
if nativeStylesheetPath = fs.resolveOnLoadPath(process.platform, ['css', 'less'])
|
||||
@requireStylesheet(nativeStylesheetPath)
|
||||
|
||||
# Internal-only:
|
||||
@@ -116,9 +118,9 @@ class ThemeManager
|
||||
# Internal-only:
|
||||
resolveStylesheet: (stylesheetPath) ->
|
||||
if path.extname(stylesheetPath).length > 0
|
||||
fsUtils.resolveOnLoadPath(stylesheetPath)
|
||||
fs.resolveOnLoadPath(stylesheetPath)
|
||||
else
|
||||
fsUtils.resolveOnLoadPath(stylesheetPath, ['css', 'less'])
|
||||
fs.resolveOnLoadPath(stylesheetPath, ['css', 'less'])
|
||||
|
||||
# Public: resolves and applies the stylesheet specified by the path.
|
||||
#
|
||||
@@ -140,7 +142,7 @@ class ThemeManager
|
||||
if path.extname(stylesheetPath) is '.less'
|
||||
@loadLessStylesheet(stylesheetPath)
|
||||
else
|
||||
fsUtils.read(stylesheetPath)
|
||||
fs.read(stylesheetPath)
|
||||
|
||||
# Internal-only:
|
||||
loadLessStylesheet: (lessStylesheetPath) ->
|
||||
|
||||
@@ -3,7 +3,7 @@ _ = require 'underscore-plus'
|
||||
ipc = require 'ipc'
|
||||
shell = require 'shell'
|
||||
{Subscriber} = require 'emissary'
|
||||
fsUtils = require './fs-utils'
|
||||
fs = require 'fs-plus'
|
||||
|
||||
# Private: Handles low-level events related to the window.
|
||||
module.exports =
|
||||
@@ -28,7 +28,7 @@ class WindowEventHandler
|
||||
@subscribe $(window), 'blur', -> $("body").addClass('is-blurred')
|
||||
|
||||
@subscribe $(window), 'window:open-path', (event, {pathToOpen, initialLine}) ->
|
||||
unless fsUtils.isDirectorySync(pathToOpen)
|
||||
unless fs.isDirectorySync(pathToOpen)
|
||||
atom.rootView?.open(pathToOpen, {initialLine})
|
||||
|
||||
@subscribe $(window), 'beforeunload', =>
|
||||
|
||||
Reference in New Issue
Block a user