diff --git a/package.json b/package.json index 40e5b96ad..fb5a14629 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "fstream": "0.1.24", "fuzzaldrin": "^2.1", "git-utils": "^3.0.0", - "grim": "1.1.2", + "grim": "1.2", "jasmine-json": "~0.0", "jasmine-tagged": "^1.1.4", "jquery": "^2.1.1", @@ -94,7 +94,7 @@ "encoding-selector": "0.18.0", "exception-reporting": "0.24.0", "find-and-replace": "0.157.0", - "fuzzy-finder": "0.66.0", + "fuzzy-finder": "0.67.0", "git-diff": "0.52.0", "go-to-line": "0.30.0", "grammar-selector": "0.45.0", diff --git a/spec/fixtures/task-handler-with-deprecations.coffee b/spec/fixtures/task-handler-with-deprecations.coffee new file mode 100644 index 000000000..6ba8e86e8 --- /dev/null +++ b/spec/fixtures/task-handler-with-deprecations.coffee @@ -0,0 +1,3 @@ +{Git} = require 'atom' + +module.exports = -> diff --git a/spec/task-spec.coffee b/spec/task-spec.coffee index 403e4650d..81a8713ad 100644 --- a/spec/task-spec.coffee +++ b/spec/task-spec.coffee @@ -1,4 +1,5 @@ Task = require '../src/task' +Grim = require 'grim' describe "Task", -> describe "@once(taskPath, args..., callback)", -> @@ -43,3 +44,16 @@ describe "Task", -> runs -> expect(eventSpy).not.toHaveBeenCalled() + + it "reports deprecations in tasks", -> + jasmine.snapshotDeprecations() + handlerPath = require.resolve('./fixtures/task-handler-with-deprecations') + task = new Task(handlerPath) + + waitsFor (done) -> task.start(done) + + runs -> + deprecations = Grim.getDeprecations() + expect(deprecations.length).toBe 1 + expect(deprecations[0].getStacks()[0][1].fileName).toBe handlerPath + jasmine.restoreDeprecationsSnapshot() diff --git a/src/task-bootstrap.coffee b/src/task-bootstrap.coffee index 4ed618d1a..ebb5cdc2b 100644 --- a/src/task-bootstrap.coffee +++ b/src/task-bootstrap.coffee @@ -41,6 +41,14 @@ handleEvents = -> result = handler.bind({async})(args...) emit('task:completed', result) unless isAsync +setupDeprecations = -> + Grim = require 'grim' + Grim.on 'updated', -> + deprecations = Grim.getDeprecations().map (deprecation) -> deprecation.serialize() + Grim.clearDeprecations() + emit('task:deprecations', deprecations) + setupGlobals() handleEvents() +setupDeprecations() handler = require(taskPath) diff --git a/src/task.coffee b/src/task.coffee index 6fe055ca6..9572494b8 100644 --- a/src/task.coffee +++ b/src/task.coffee @@ -1,6 +1,7 @@ _ = require 'underscore-plus' {fork} = require 'child_process' {Emitter} = require 'emissary' +Grim = require 'grim' # Extended: Run a node script in a separate process. # @@ -87,6 +88,9 @@ class Task @on "task:log", -> console.log(arguments...) @on "task:warn", -> console.warn(arguments...) @on "task:error", -> console.error(arguments...) + @on "task:deprecations", (deprecations) -> + Grim.addSerializedDeprecation(deprecation) for deprecation in deprecations + return @on "task:completed", (args...) => @callback?(args...) @handleEvents()