Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #10286 from luzmcosta/perf/requires
Browse files Browse the repository at this point in the history
Optimizes fs-extra `require`.
  • Loading branch information
bsclifton committed Aug 7, 2017
1 parent 4f911f2 commit 9203d68
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/sessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// - NODE_ENV of ‘test’ bypassing session state or else they all fail.

const Immutable = require('immutable')
const fs = require('fs-extra')
const path = require('path')
const electron = require('electron')
const os = require('os')
Expand Down Expand Up @@ -544,7 +543,10 @@ module.exports.runImportDefaultSettings = (data) => {
*/
module.exports.loadAppState = () => {
return new Promise((resolve, reject) => {
const fs = require('fs')

let data

try {
data = fs.readFileSync(getStoragePath())
} catch (e) {}
Expand Down Expand Up @@ -607,6 +609,7 @@ module.exports.loadAppState = () => {
* Called when session is suspected for corruption; this will move it out of the way
*/
module.exports.backupSession = () => {
const fs = require('fs-extra')
const src = getStoragePath()
const dest = getTempStoragePath('backup')

Expand Down
1 change: 1 addition & 0 deletions test/unit/app/sessionStoreTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe('sessionStore unit tests', function () {
useCleanCache: true
})
mockery.registerMock('fs-extra', fakeFileSystem)
mockery.registerMock('fs', fakeFileSystem)
mockery.registerMock('electron', fakeElectron)
mockery.registerMock('./locale', fakeLocale)
mockery.registerMock('../js/state/siteUtil', mockSiteUtil)
Expand Down

0 comments on commit 9203d68

Please sign in to comment.