Skip to content

Commit

Permalink
🐛 Clear require cache on main module loading
Browse files Browse the repository at this point in the history
I expect it to fix the various issues due to not all the files being
reloaded on update.
  • Loading branch information
abe33 committed Dec 16, 2015
1 parent 8d0f061 commit 1b698ab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
'use babel'

/*
The following hack clears the require cache of all the paths to the minimap when this file is laoded. It should prevents errors of partial reloading after an update.
*/
import path from 'path'
Object.keys(require.cache).filter((p) => {
return p !== __filename && p.indexOf(path.resolve(__dirname, '..') + path.sep) > -1
}).forEach((p) => {
delete require.cache[p]
})

import {Emitter, CompositeDisposable} from 'atom'
import include from './decorators/include'
import Minimap from './minimap'
Expand Down Expand Up @@ -81,7 +91,7 @@ class Main {
activate () {
if (this.active) { return }

MinimapElement.registerViewProvider()
MinimapElement.registerViewProvider(Minimap)

this.subscriptionsOfCommands = atom.commands.add('atom-workspace', {
'minimap:toggle': () => {
Expand Down
4 changes: 2 additions & 2 deletions lib/minimap-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export default class MinimapElement {
* The method that registers the MinimapElement factory in the
* `atom.views` registry with the Minimap model.
*/
static registerViewProvider () {
atom.views.addViewProvider(require('./minimap'), function (model) {
static registerViewProvider (Minimap) {
atom.views.addViewProvider(Minimap, function (model) {
let element = new MinimapElement()
element.setModel(model)
return element
Expand Down

0 comments on commit 1b698ab

Please sign in to comment.