fix(imports): switch to Electron's require('electron') (#1907)

* fix(imports): switch to Electron's require('electron')

Electron in 0.37.5 phases out the usage of `require('built-in-module')`
in favor of `require('electron').builtInModule`. This commit corrects usage in
some cases that cause N1 to not start under Electron 0.37.5.

* fix(specs): use new Electron remote import
This commit is contained in:
Matt Bilker 2016-04-12 21:09:13 -04:00 committed by Ben Gotow
parent fad1594c01
commit 5fd8faa82c
4 changed files with 14 additions and 7 deletions

View file

@ -1,8 +1,10 @@
import fs from 'fs'; import fs from 'fs';
import shell from 'shell'; import { remote } from 'electron';
import {Message, DraftStore} from 'nylas-exports'; import {Message, DraftStore} from 'nylas-exports';
import TemplateStore from '../lib/template-store'; import TemplateStore from '../lib/template-store';
const { shell } = remote;
const stubTemplatesDir = '~/.nylas/templates'; const stubTemplatesDir = '~/.nylas/templates';
const stubTemplateFiles = { const stubTemplateFiles = {

View file

@ -2,9 +2,11 @@ import React from 'react';
import _ from 'underscore'; import _ from 'underscore';
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
import shell from 'shell'; import { remote } from 'electron';
import {Flexbox} from 'nylas-component-kit'; import { Flexbox } from 'nylas-component-kit';
const { shell } = remote;
const displayedKeybindings = [ const displayedKeybindings = [
{ {

View file

@ -15,7 +15,7 @@ DatabaseChangeRecord = require './database-change-record'
DatabaseTransaction = require './database-transaction' DatabaseTransaction = require './database-transaction'
JSONBlob = null JSONBlob = null
{ipcRenderer} = require 'electron' {remote, ipcRenderer} = require 'electron'
DatabaseVersion = 23 DatabaseVersion = 23
DatabasePhase = DatabasePhase =
@ -108,7 +108,7 @@ class DatabaseStore extends NylasStore
_onPhaseChange: (event) => _onPhaseChange: (event) =>
return if NylasEnv.inSpecMode() return if NylasEnv.inSpecMode()
app = require('remote').getGlobal('application') app = remote.getGlobal('application')
phase = app.databasePhase() phase = app.databasePhase()
if phase is DatabasePhase.Setup and NylasEnv.isWorkWindow() if phase is DatabasePhase.Setup and NylasEnv.isWorkWindow()
@ -135,7 +135,7 @@ class DatabaseStore extends NylasStore
# extremely frequently as new models are added when packages load. # extremely frequently as new models are added when packages load.
refreshDatabaseSchema: -> refreshDatabaseSchema: ->
return unless NylasEnv.isWorkWindow() return unless NylasEnv.isWorkWindow()
app = require('remote').getGlobal('application') app = remote.getGlobal('application')
phase = app.databasePhase() phase = app.databasePhase()
if phase isnt DatabasePhase.Setup if phase isnt DatabasePhase.Setup
app.setDatabasePhase(DatabasePhase.Setup) app.setDatabasePhase(DatabasePhase.Setup)

View file

@ -9,6 +9,9 @@ window.eval = global.eval = function() {
var path = require('path'); var path = require('path');
var electron = require('electron');
var remote = electron.remote;
function setLoadTime (loadTime) { function setLoadTime (loadTime) {
if (global.NylasEnv) { if (global.NylasEnv) {
global.NylasEnv.loadTime = loadTime global.NylasEnv.loadTime = loadTime
@ -17,7 +20,7 @@ function setLoadTime (loadTime) {
} }
function handleSetupError (error) { function handleSetupError (error) {
var currentWindow = require('remote').getCurrentWindow() var currentWindow = remote.getCurrentWindow()
currentWindow.setSize(800, 600) currentWindow.setSize(800, 600)
currentWindow.center() currentWindow.center()
currentWindow.show() currentWindow.show()