Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/controller/service-controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,16 @@ module.exports = ServiceController =
@config.initialise obj

onSave: (obj) ->
config = @config.load obj
@onSync obj, 'up' if config?.behaviour?.uploadOnSave
config = @config.loadReal obj
@onSync config.filename, 'up' if config?.behaviour?.uploadOnSave

onOpen: (obj) ->
config = @config.load obj
@onSync obj, 'down' if config?.behaviour?.syncDownOnOpen
config = @config.loadReal obj
@onSync config.filename, 'down' if config?.behaviour?.syncDownOnOpen

onSync: (obj, direction) ->
obj = path.normalize obj

try
obj = path.normalize obj
config = @config.assert obj
catch err
@console.show()
Expand Down
13 changes: 13 additions & 0 deletions lib/helper/config-helper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ module.exports = ConfigHelper =
return if not config or not fs.isFileSync config
cson.readFileSync config

loadReal: (f) ->
config = @load f
if config
config.filename = f
else
for fRealPath in atom.project.getPaths()
if (f.indexOf fRealPath) is -1
config = cson.readFileSync fRealPath + '/' + @configFileName
if config and (f.indexOf config?.option?.localRoot) isnt -1
config.filename = fRealPath + f.substr config.option.localRoot.length
config

assert: (f) ->
config = @load f
if not config then throw new Error "You must create remote config first"
Expand Down Expand Up @@ -52,6 +64,7 @@ module.exports = ConfigHelper =
alwaysSyncAll: false
option:
deleteFiles: false
localRoot: false
exclude: [
'.sync-config.cson'
'.git'
Expand Down