autoreload-package-service

a reloader for atom packages

Paul Pflugradt

769

0

0.0.4

GitHub

This package provides the following services:

This package consumes the following services:

autoreload-package-service

provides a service which other packages can use to reload on file change

autoreload-package-service

Only works in dev mode!

Usage

package.json

{
  ...
  "consumedServices": {
    "autoreload": {
      "versions": {
        "^0.0.1": "consumeAutoreload"
      }
    }
  }
  ...
}

your package:

  #in main module
  consumeAutoreload: (reloader) ->
    reloader(pkg:"nameOfYourPackage",files:["package.json"],folders:["lib/"])
    # pkg has to be the name of your package and is required
    # files are watched and your package reloaded on changes, defaults to ["package.json"]
    # folders are watched and your package reloaded on changes, defaults to ["lib/"]

Keep in mind, the service wont be loaded if your activate function throws an error. This is recommended:

  #in main module
  activate: ->
    realActivate = ->
      #do your stuff
    if atom.inDevMode()
      try
        realActivate()
      catch e
        console.log e
    else
      realActivate()
  #make sure your deactivate wont throw, even when realActivate wasn't successful
  deactivate: ->
    somestuff?.dispose()

License

Copyright (c) 2015 Paul Pflugradt Licensed under the MIT license.