Skip to content

Commit

Permalink
Report action.start, action.finish
Browse files Browse the repository at this point in the history
  • Loading branch information
andreyvit committed Oct 23, 2012
1 parent 8e1e7d7 commit 6a3913c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/plugins/compilation.iced
Expand Up @@ -99,9 +99,12 @@ class CompilationStep

'$(additional)': []

action = { id: 'compile', message: "Compiling #{srcInfo.file}" }
invocation = compiler.tool.createInvocation(info)

invocation.once 'finished', ->
@project.reportActionStart(action)
invocation.once 'finished', =>
@project.reportActionFinish(action)
callback(dstRelPath)
invocation.run()

Expand Down
5 changes: 4 additions & 1 deletion lib/plugins/postproc.iced
Expand Up @@ -69,6 +69,9 @@ class PostProcStep
'$(projectDir)': @project.fullPath
invocation = tool.createInvocation(info)

invocation.once 'finished', ->
action = { id: 'postproc', message: "Running #{@project.postprocCommand}" }
@project.reportActionStart(action)
invocation.once 'finished', =>
@project.reportActionFinish(action)
callback(null)
invocation.run()
5 changes: 5 additions & 0 deletions lib/plugins/refresh.iced
Expand Up @@ -40,11 +40,15 @@ class RefreshStep

_perform: (request, done) ->
debug "Executing browser refresh job: " + JSON.stringify(request)
return done(null) if request.paths.length == 0

# json_object_set_new(arg, "path", json_string(request->path));
# json_object_set_new(arg, "originalPath", json_string(request->original_path ?: ""));
# json_object_set_new(arg, "liveCSS", !project.disableLiveRefresh ? json_true() : json_false());
# json_object_set_new(arg, "enableOverride", project.enableRemoteServerWorkflow ? json_true() : json_false());
# _fullPageReloadDelay!!
action = { id: 'refresh', message: "Refreshing browser" }
@project.reportActionStart(action)
for path in request.paths
command =
command: 'reload'
Expand All @@ -57,5 +61,6 @@ class RefreshStep
# message.overrideURL = @urlOverrideCoordinator.createOverrideURL(path)

@session.sendBrowserCommand command
@project.reportActionFinish(action)

done(null)
3 changes: 3 additions & 0 deletions lib/projects/analyzer.iced
Expand Up @@ -69,6 +69,9 @@ class Analyzer
return callback()

debug "#{analyzer}: analyzing #{relpath}"
action = { id: 'analyze', message: "Analyzing #{Path.basename(relpath)}"}
@project.reportActionStart(action)
await analyzer.update relpath, fullPath, defer()
@project.reportActionFinish(action)

callback()
10 changes: 10 additions & 0 deletions lib/projects/project.iced
Expand Up @@ -202,6 +202,16 @@ class Project extends R.Model

return run

reportActionStart: (action) ->
if !action.id
throw new Error("Invalid argument: action.id is required")
@emit 'action.start', action

reportActionFinish: (action) ->
if !action.id
throw new Error("Invalid argument: action.id is required")
@emit 'action.finish', action

patchSourceFile: (oldCompiled, newCompiled, callback) ->
oldLines = oldCompiled.trim().split("\n")
newLines = newCompiled.trim().split("\n")
Expand Down
4 changes: 4 additions & 0 deletions lib/session.iced
Expand Up @@ -103,6 +103,10 @@ class Session extends EventEmitter
_addProject: (project) ->
project.on 'change', (path) =>
@emit 'command', command: 'reload', path: path
project.on 'action.start', (action) =>
@emit 'action.start', project, action
project.on 'action.finish', (action) =>
@emit 'action.finish', project, action
project.on 'run.start', (run) =>
@emit 'run.start', project, run
project.on 'run.finish', (run) =>
Expand Down

0 comments on commit 6a3913c

Please sign in to comment.