kill Process, split into fs module and system module

This commit is contained in:
Chris Wanstrath 2011-09-03 23:18:52 -07:00
parent 8b0b0e4ea3
commit 2b1e04264c
6 changed files with 21 additions and 16 deletions

View File

@ -1,7 +1,7 @@
$ = require 'jquery'
_ = require 'underscore'
{Chrome, Process} = require 'osx'
{Chrome} = require 'osx'
File = require 'fs'
Editor = require 'editor'
@ -14,7 +14,7 @@ exports.init = ->
@toggle()
Editor.ace.on 'open', =>
@reload() if @dir? and Process.cwd() isnt @dir
@reload() if @dir? and File.workingDirectory() isnt @dir
$('#project .cwd').live 'click', (event) =>
Editor.open @dir.replace _.last(@dir.split '/'), ''
@ -36,7 +36,7 @@ exports.toggle = ->
@showing = not @showing
exports.reload = ->
@dir = dir = Process.cwd()
@dir = dir = File.workingDirectory()
$('#project .cwd').text _.last dir.split '/'
$('#project li').remove()

View File

@ -1,7 +1,7 @@
$ = require 'jquery'
_ = require 'underscore'
{Chrome, Process} = require 'osx'
{Chrome} = require 'osx'
File = require 'fs'
{bindKey} = require 'editor'

View File

@ -3,7 +3,7 @@
$ = require 'jquery'
_ = require 'underscore'
{Chrome, Process} = require 'osx'
{Chrome} = require 'osx'
File = require 'fs'
ace = require 'ace/ace'
@ -25,7 +25,7 @@ exports.open = open = (path) ->
filename = path
if File.isDir filename
Process.cwd filename
File.changeWorkingDirectory filename
Chrome.title _.last filename.split '/'
editor.getSession().setValue ""
Chrome.setDirty false

View File

@ -12,6 +12,10 @@ module.exports =
else
path
# Set the current working directory to `path`.
changeWorkingDirectory: (path) ->
OSX.NSFileManager.defaultManager.changeCurrentDirectoryPath path
# Returns true if the file specified by path exists and is a
# directory.
isDirectory: (path) ->
@ -54,3 +58,7 @@ module.exports =
write: (path, content) ->
str = OSX.NSString.stringWithString content
str.writeToFile_atomically @absolute(path), true
# Return the path name of the current working directory.
workingDirectory: ->
OSX.NSFileManager.defaultManager.currentDirectoryPath.toString()

View File

@ -87,16 +87,6 @@ Chrome =
appRoot: ->
OSX.NSBundle.mainBundle.resourcePath
Process =
cwd: (path) ->
if path?
OSX.NSFileManager.defaultManager.changeCurrentDirectoryPath path
else
OSX.NSFileManager.defaultManager.currentDirectoryPath.toString()
env: ->
OSX.NSProcess.processInfo.environment
exports.Chrome = Chrome
exports.File = File
exports.Dir = Dir

7
src/system.coffee Normal file
View File

@ -0,0 +1,7 @@
# commonjs system module
# http://ringojs.org/api/v0.8/system/
module.exports = ->
# An object containing our environment variables.
env: ->
OSX.NSProcess.processInfo.environment