fix(build): Fix specs and lint errors

Summary: Fix specs and lint errors

Test Plan: Unit

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3168
This commit is contained in:
Juan Tejada 2016-08-16 17:36:46 -07:00
parent 4aa4a0eed9
commit 43d02da5d9
2 changed files with 82 additions and 74 deletions

View file

@ -10,79 +10,81 @@ import {ipcRenderer} from 'electron'
* leave their app in the /Downloads folder (which frequently gets
* erased!).
*/
module.exports = {
activate() {
this._unlisten = Actions.notificationActionTaken.listen(this._onNotificationActionTaken, this)
if (NylasEnv.inDevMode() || NylasEnv.inSpecMode()) return;
if (process.platform === "darwin") {
const appRe = /Applications/gi;
if (appRe.test(process.argv[0])) return;
let unlisten = () => {}
// If we're in Volumes, that means we've launched from the DMG. This
// is unsupported. We should optimistically move.
const volTest = /Volumes/gi;
if (volTest.test(process.argv[0])) {
ipcRenderer.send("move-to-applications");
return;
}
const numAsks = NylasEnv.config.get("asksAboutAppMove")
if (numAsks >= 5) return;
const actions = []
if (numAsks >= 1) {
actions.push({
label: "Don't ask again",
dismisses: true,
id: 'verify-install:dont-ask-again',
})
}
const re = /(^.*?\.app)/i;
let enclosingFolder = (re.exec(process.argv[0]) || [])[0].split("/");
enclosingFolder = enclosingFolder[enclosingFolder.length - 2]
let msg = `I can move myself to your Applications folder if you'd like.`
if (enclosingFolder) {
msg += ` This will keep your ${enclosingFolder} folder uncluttered.`
}
Actions.postNotification({
type: 'info',
tag: 'app-update',
sticky: true,
message: msg,
icon: 'fa-flag',
actions: actions.concat([
{
label: "Do Not Move",
dismisses: true,
id: 'verify-install:do-not-move',
},
{
"label": "Move to Applications Folder",
"dismisses": true,
"default": true,
"id": 'verify-install:move-to-applications',
},
]),
});
}
},
_onNotificationActionTaken({action}) {
if (action.id === "verify-install:dont-ask-again") {
NylasEnv.config.set("asksAboutAppMove", 5)
} else if (action.id === "verify-install:do-not-move") {
const numAsks = NylasEnv.config.get("asksAboutAppMove") || 0
NylasEnv.config.set("asksAboutAppMove", numAsks + 1)
} else if (action.id === "verify-install:move-to-applications") {
ipcRenderer.send("move-to-applications")
}
},
deactivate() {
this._unlisten()
},
function onNotificationActionTaken({action}) {
if (action.id === "verify-install:dont-ask-again") {
NylasEnv.config.set("asksAboutAppMove", 5)
} else if (action.id === "verify-install:do-not-move") {
const numAsks = NylasEnv.config.get("asksAboutAppMove") || 0
NylasEnv.config.set("asksAboutAppMove", numAsks + 1)
} else if (action.id === "verify-install:move-to-applications") {
ipcRenderer.send("move-to-applications")
}
}
export function activate() {
unlisten = Actions.notificationActionTaken.listen(onNotificationActionTaken)
if (NylasEnv.inDevMode() || NylasEnv.inSpecMode()) { return; }
if (process.platform !== "darwin") { return; }
const appRe = /Applications/gi;
if (appRe.test(process.argv[0])) { return; }
// If we're in Volumes, that means we've launched from the DMG. This
// is unsupported. We should optimistically move.
const volTest = /Volumes/gi;
if (volTest.test(process.argv[0])) {
ipcRenderer.send("move-to-applications");
return;
}
const numAsks = NylasEnv.config.get("asksAboutAppMove")
if (numAsks >= 5) return;
const actions = []
if (numAsks >= 1) {
actions.push({
label: "Don't ask again",
dismisses: true,
id: 'verify-install:dont-ask-again',
})
}
const re = /(^.*?\.app)/i;
let enclosingFolder = (re.exec(process.argv[0]) || [])[0].split("/");
enclosingFolder = enclosingFolder[enclosingFolder.length - 2]
let msg = `I can move myself to your Applications folder if you'd like.`
if (enclosingFolder) {
msg += ` This will keep your ${enclosingFolder} folder uncluttered.`
}
Actions.postNotification({
type: 'info',
tag: 'app-update',
sticky: true,
message: msg,
icon: 'fa-flag',
actions: actions.concat([
{
label: "Do Not Move",
dismisses: true,
id: 'verify-install:do-not-move',
},
{
"label": "Move to Applications Folder",
"dismisses": true,
"default": true,
"id": 'verify-install:move-to-applications',
},
]),
});
}
export function deactivate() {
unlisten()
}

View file

@ -120,6 +120,12 @@ require('moment-round')
window.testNowMoment = ->
moment.tz("2016-03-15 12:00", TEST_TIME_ZONE)
# We need to mock the config even before `beforeEach` runs because it gets
# accessed on module definitions
fakePersistedConfig = {env: 'production'}
NylasEnv.config = new Config()
NylasEnv.config.settings = fakePersistedConfig
beforeEach ->
NylasEnv.testOrganizationUnit = null
Grim.clearDeprecations() if isCoreSpec
@ -196,7 +202,7 @@ beforeEach ->
FocusedPerspectiveStore._current = MailboxPerspective.forNothing()
# reset config before each spec; don't load or save from/to `config.json`
fakePersistedConfig = {}
fakePersistedConfig = {env: 'production'}
spyOn(Config::, 'getRawValues').andCallFake =>
fakePersistedConfig
spyOn(Config::, 'setRawValue').andCallFake (keyPath, value) ->