mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Support specifying main module in package.cson
Migrated strip-trailing-whitespace package to include a package.cson with a main being a file in the lib directory instead of the index.coffee at the root of the package.
This commit is contained in:
committed by
Corey Johnson & Kevin Sawicki
parent
856b378f54
commit
d884bf58e8
@@ -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)
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
AtomPackage = require 'atom-package'
|
||||
|
||||
module.exports =
|
||||
class StripTrailingWhitespace extends AtomPackage
|
||||
activate: (rootView) ->
|
||||
rootView.eachBuffer (buffer) => @stripTrailingWhitespaceBeforeSave(buffer)
|
||||
|
||||
1
src/packages/strip-trailing-whitespace/package.cson
Normal file
1
src/packages/strip-trailing-whitespace/package.cson
Normal file
@@ -0,0 +1 @@
|
||||
'main': 'strip-trailing-whitespace/lib/strip-trailing-whitespace'
|
||||
Reference in New Issue
Block a user