mirror of
https://github.com/atom/atom.git
synced 2026-02-08 13:45:09 -05:00
move Dir into fs.coffee and commonjs it
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
|
||||
{Chrome, Process, Dir} = require 'osx'
|
||||
{Chrome, Process} = require 'osx'
|
||||
File = require 'fs'
|
||||
|
||||
ace = require 'ace/ace'
|
||||
@@ -24,7 +24,7 @@ save = ->
|
||||
exports.open = open = (path) ->
|
||||
filename = path
|
||||
|
||||
if Dir.isDir filename
|
||||
if File.isDir filename
|
||||
Process.cwd filename
|
||||
Chrome.title _.last filename.split '/'
|
||||
editor.getSession().setValue ""
|
||||
|
||||
@@ -12,6 +12,14 @@ module.exports =
|
||||
else
|
||||
path
|
||||
|
||||
# Returns true if the file specified by path exists and is a
|
||||
# directory.
|
||||
isDirectory: (path) ->
|
||||
isDir = new jscocoa.outArgument
|
||||
exists = OSX.NSFileManager.defaultManager.
|
||||
fileExistsAtPath_isDirectory path, isDir
|
||||
exists and isDir.valueOf()
|
||||
|
||||
# Returns true if the file specified by path exists and is a
|
||||
# regular file.
|
||||
isFile: (path) ->
|
||||
@@ -20,6 +28,24 @@ module.exports =
|
||||
fileExistsAtPath_isDirectory path, isDir
|
||||
exists and not isDir.valueOf()
|
||||
|
||||
# Returns an array with all the names of files contained
|
||||
# in the directory path.
|
||||
list: (path, recursive) ->
|
||||
path = File.absolute path
|
||||
fm = OSX.NSFileManager.defaultManager
|
||||
if recursive
|
||||
paths = fm.subpathsAtPath path
|
||||
else
|
||||
paths = fm.contentsOfDirectoryAtPath_error path, null
|
||||
_.map paths, (entry) -> "#{path}/#{entry}"
|
||||
|
||||
# Return an array with all directories below (and including)
|
||||
# the given path, as discovered by depth-first traversal. Entries
|
||||
# are in lexically sorted order within directories. Symbolic links
|
||||
# to directories are not traversed into.
|
||||
listDirectoryTree: (path) ->
|
||||
@list path, true
|
||||
|
||||
# Open, read, and close a file, returning the file's contents.
|
||||
read: (path) ->
|
||||
OSX.NSString.stringWithContentsOfFile(@absolute path).toString()
|
||||
|
||||
@@ -87,22 +87,6 @@ Chrome =
|
||||
appRoot: ->
|
||||
OSX.NSBundle.mainBundle.resourcePath
|
||||
|
||||
# Handles the file system
|
||||
Dir =
|
||||
list: (path, recursive) ->
|
||||
path = File.absolute path
|
||||
fm = OSX.NSFileManager.defaultManager
|
||||
if recursive
|
||||
paths = fm.subpathsAtPath path
|
||||
else
|
||||
paths = fm.contentsOfDirectoryAtPath_error path, null
|
||||
_.map paths, (entry) -> "#{path}/#{entry}"
|
||||
isDir: (path) ->
|
||||
isDir = new jscocoa.outArgument
|
||||
exists = OSX.NSFileManager.defaultManager.
|
||||
fileExistsAtPath_isDirectory path, isDir
|
||||
exists and isDir.valueOf()
|
||||
|
||||
Process =
|
||||
cwd: (path) ->
|
||||
if path?
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
|
||||
{Chrome, Dir} = require 'osx'
|
||||
{Chrome} = require 'osx'
|
||||
File = require 'fs'
|
||||
|
||||
_.map Dir.list(Chrome.appRoot() + "/plugins"), (plugin) ->
|
||||
_.map File.list(Chrome.appRoot() + "/plugins"), (plugin) ->
|
||||
require plugin
|
||||
|
||||
if css = File.read "~/.atomicity/twilight.css"
|
||||
@@ -15,5 +15,5 @@ if css = File.read "~/.atomicity/twilight.css"
|
||||
style.appendChild rules
|
||||
head.appendChild style
|
||||
|
||||
_.map Dir.list("~/.atomicity/"), (path) ->
|
||||
_.map File.list("~/.atomicity/"), (path) ->
|
||||
require path
|
||||
|
||||
Reference in New Issue
Block a user