diff --git a/spec/fixtures/packages/package-with-no-activate/index.js b/spec/fixtures/packages/package-with-no-activate/index.js new file mode 100644 index 000000000..4ba52ba2c --- /dev/null +++ b/spec/fixtures/packages/package-with-no-activate/index.js @@ -0,0 +1 @@ +module.exports = {} diff --git a/spec/fixtures/packages/package-with-no-activate/package.json b/spec/fixtures/packages/package-with-no-activate/package.json new file mode 100644 index 000000000..4be70fd1a --- /dev/null +++ b/spec/fixtures/packages/package-with-no-activate/package.json @@ -0,0 +1,4 @@ +{ + "name": "package-with-no-activate", + "version": "1.0.0" +} diff --git a/spec/package-manager-spec.coffee b/spec/package-manager-spec.coffee index 3d79b4631..d9898505c 100644 --- a/spec/package-manager-spec.coffee +++ b/spec/package-manager-spec.coffee @@ -220,6 +220,17 @@ describe "PackageManager", -> expect(console.error).not.toHaveBeenCalled() expect(console.warn).not.toHaveBeenCalled() + describe "when the package does not export an activate function", -> + it "activates the package and does not throw an exception or log a warning", -> + spyOn(console, "warn") + expect(-> atom.packages.activatePackage('package-with-no-activate')).not.toThrow() + + waitsFor -> + atom.packages.isPackageActive('package-with-no-activate') + + runs -> + expect(console.warn).not.toHaveBeenCalled() + it "passes the activate method the package's previously serialized state if it exists", -> pack = null waitsForPromise -> diff --git a/src/package.coffee b/src/package.coffee index 6a94133d6..d8ba4a1d8 100644 --- a/src/package.coffee +++ b/src/package.coffee @@ -157,7 +157,7 @@ class Package @activateConfig() @activateStylesheets() if @requireMainModule() - @mainModule.activate(atom.packages.getPackageState(@name) ? {}) + @mainModule.activate?(atom.packages.getPackageState(@name) ? {}) @mainActivated = true @activateServices() catch e