diff --git a/src/app/atom-package.coffee b/src/app/atom-package.coffee index 291bb7ae4..4b0ebe55b 100644 --- a/src/app/atom-package.coffee +++ b/src/app/atom-package.coffee @@ -16,11 +16,19 @@ class AtomPackage extends Package @loadMetadata() @loadKeymaps() @loadStylesheets() if @autoloadStylesheets - rootView?.activatePackage(@name, this) if require.resolve(@path) + if packageMain = @getPackageMain() + rootView?.activatePackage(@name, packageMain) catch e console.warn "Failed to load package named '#{@name}'", e.stack this + getPackageMain: -> + mainPath = require.resolve(@metadata.main) if @metadata.main + if mainPath + require(mainPath) + else if require.resolve(@path) + this + loadMetadata: -> if metadataPath = fs.resolveExtension(fs.join(@path, "package"), ['cson', 'json']) @metadata = fs.readObject(metadataPath) diff --git a/src/packages/strip-trailing-whitespace/index.coffee b/src/packages/strip-trailing-whitespace/lib/strip-trailing-whitespace.coffee similarity index 87% rename from src/packages/strip-trailing-whitespace/index.coffee rename to src/packages/strip-trailing-whitespace/lib/strip-trailing-whitespace.coffee index 20b3e6d74..bf01c6bbe 100644 --- a/src/packages/strip-trailing-whitespace/index.coffee +++ b/src/packages/strip-trailing-whitespace/lib/strip-trailing-whitespace.coffee @@ -1,7 +1,4 @@ -AtomPackage = require 'atom-package' - module.exports = -class StripTrailingWhitespace extends AtomPackage activate: (rootView) -> rootView.eachBuffer (buffer) => @stripTrailingWhitespaceBeforeSave(buffer) diff --git a/src/packages/strip-trailing-whitespace/package.cson b/src/packages/strip-trailing-whitespace/package.cson new file mode 100644 index 000000000..25e3026d8 --- /dev/null +++ b/src/packages/strip-trailing-whitespace/package.cson @@ -0,0 +1 @@ +'main': 'strip-trailing-whitespace/lib/strip-trailing-whitespace'