Skip to content

Commit

Permalink
Fix npm clean commands
Browse files Browse the repository at this point in the history
Auditors: @bridiver

Fix brave#3912

Test Plan:
- Make sure the release bundled app is still linked to the session-store-1 file under the brave userData dir.  You can check by moving away your session-store-1 file and making sure it clears your app data.
- Run npm run clean-session-store and make sure the
session-store-1 file under the brave-development folder gets removed
  • Loading branch information
bbondy authored and MKuenzi committed Sep 18, 2016
1 parent 55c74f8 commit 8ff8243
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
15 changes: 15 additions & 0 deletions app/browser/lib/patchUserDataDir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

const path = require('path')
const {app} = require('electron')

if (!process.env.BRAVE_USER_DATA_DIR && ['development', 'test'].includes(process.env.NODE_ENV)) {
process.env.BRAVE_USER_DATA_DIR = path.join(app.getPath('appData'), app.getName() + '-' + process.env.NODE_ENV)
}

if (process.env.BRAVE_USER_DATA_DIR) {
app.setPath('userData', process.env.BRAVE_USER_DATA_DIR)
}

9 changes: 1 addition & 8 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,10 @@ if (process.platform === 'win32') {
require('./windowsInit')
}

const path = require('path')
const electron = require('electron')
const app = electron.app
// set userData before loading anything else
if (!process.env.BRAVE_USER_DATA_DIR && ['development', 'test'].includes(process.env.NODE_ENV)) {
process.env.BRAVE_USER_DATA_DIR = path.join(app.getPath('appData'), app.getName() + '-' + process.env.NODE_ENV)
}

if (process.env.BRAVE_USER_DATA_DIR) {
app.setPath('userData', process.env.BRAVE_USER_DATA_DIR)
}
require('./browser/lib/patchUserDataDir')
const BrowserWindow = electron.BrowserWindow
const dialog = electron.dialog
const ipcMain = electron.ipcMain
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"clean-adblock-data": "node ./tools/clean.js userData ABPFilterParserData.dat",
"clean-httpse-data": "node ./tools/clean.js userData httpse.json",
"clean-sb-data": "node ./tools/clean.js userData SafeBrowsingData.dat",
"clean-session-store": "node ./tools/clean.js userData session-store-1-dev",
"clean-session-store": "node ./tools/clean.js userData session-store-1",
"clean-tp-data": "node ./tools/clean.js userData TrackingProtection.dat",
"docs": "jsdox js/actions/appActions.js js/actions/windowActions.js --output docs",
"download-languages": "node ./tools/downloadLanguages",
Expand Down
2 changes: 1 addition & 1 deletion tools/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports.userData = (file = process.argv[3]) => {
}

module.exports.sessionStore = () => {
module.exports.userData('session-store-1-dev')
module.exports.userData('session-store-1')
}

module.exports.dataFiles = () => {
Expand Down
7 changes: 4 additions & 3 deletions tools/lib/utilApp/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict'

const path = require('path')
const rimraf = require('../rimraf')
const electron = require('electron')
const app = electron.app
app.setName('brave')
app.setPath('userData', path.join(app.getPath('appData'), app.getName()))
require('../../../app/browser/lib/patchUserDataDir')

const path = require('path')
const rimraf = require('../rimraf')

const cleanUserData = (location) => {
location = location ? path.join(app.getPath('userData'), location) : app.getPath('userData')
Expand Down

0 comments on commit 8ff8243

Please sign in to comment.