diff --git a/src/browser.js b/src/browser.js index b9123e8..24e453a 100644 --- a/src/browser.js +++ b/src/browser.js @@ -69,6 +69,12 @@ app.on('ready', function () { autoUpdater.quitAndInstall(); }); + ipc.on('deconst:preparer-completion', function () { + if (!mainWindow || !mainWindow.isFocused()) { + app.dock.bounce(); + } + }); + if (os.platform() === 'win32') { mainWindow.on('close', function () { mainWindow.webContents.send('application:quitting'); diff --git a/src/stores/ContentRepositoryStore.js b/src/stores/ContentRepositoryStore.js index 18f1741..41a66f7 100644 --- a/src/stores/ContentRepositoryStore.js +++ b/src/stores/ContentRepositoryStore.js @@ -56,7 +56,7 @@ class ContentRepositoryStore { ContentRepositoryUtil.launchControlPreparer(r); let installWatcher = (root, fn, callback) => { - let ignored = ['_build/**', '_site/**', '.git/**', '.DS_Store', 'npm-debug.log', 'build', + let ignored = ['_build/**', '_site/**', '.git/**', '.DS_Store', 'npm-debug.log*', 'build', '**/node_modules/**']; let gitignorePath = path.join(root, ".gitignore"); @@ -164,40 +164,13 @@ class ContentRepositoryStore { // Identify which repository this container belongs to, if any. for(let id in this.repositories) { let r = this.repositories[id]; + if (r.contentPreparerContainer && r.contentPreparerContainer.Id === container.Id) { - r.contentPreparerContainer = null; - - // This repository's preparer has completed. - if (container.State.ExitCode === 0) { - // Clean exit. Hooray! - if (!r.isPreparing()) { - r.state = "ready"; - r.hasPrepared = true; - } - } else if (container.State.ExitCode === 137) { - // Killed, presumably to run a new preparer. - } else { - // Boom! Something went wrong. - r.reportError(`The content preparer exited with status ${container.State.ExitCode}.`); - } + r.reportPreparerComplete(container); } if (r.controlPreparerContainer && r.controlPreparerContainer.Id === container.Id) { - // The control preparer has completed. - r.controlPreparerContainer = null; - - if (container.State.ExitCode === 0) { - // Clean exit. Hooray! - if (!r.isPreparing()) { - r.state = "ready"; - r.hasPrepared = true; - } - } else if (container.State.ExitCode === 137) { - // Killed, presumably to run a new preparer. - } else { - // Boom! Something went wrong. - r.reportError(`The control preparer exited with status ${container.State.ExitCode}.`); - } + r.reportPreparerComplete(container); } if (r.contentContainer && r.contentContainer.Id === container.Id) { diff --git a/src/utils/ContentRepositoryUtil.js b/src/utils/ContentRepositoryUtil.js index d815e3c..fd3a402 100644 --- a/src/utils/ContentRepositoryUtil.js +++ b/src/utils/ContentRepositoryUtil.js @@ -7,6 +7,7 @@ import mkdirp from 'mkdirp'; import osenv from 'osenv'; import urlJoin from 'url-join'; import _ from 'underscore'; +import ipc from 'ipc'; import DockerUtil from './DockerUtil'; import ContentRepositoryActions from '../actions/ContentRepositoryActions'; @@ -178,6 +179,38 @@ export class ContentRepository { }; } + reportPreparerComplete(container) { + let preparerName; + + if (this.contentPreparerContainer && this.contentPreparerContainer.Id === container.Id) { + this.contentPreparerContainer = null; + preparerName = "content"; + } + + if (this.controlPreparerContainer && this.controlPreparerContainer.Id === container.Id) { + this.controlPreparerContainer = null; + preparerName = "control"; + } + + if (!preparerName) { + return; + } + + if (container.State.ExitCode === 0) { + // Clean exit. Hooray! + if (!this.isPreparing()) { + this.state = "ready"; + this.hasPrepared = true; + ipc.send('deconst:preparer-completion'); + } + } else if (container.State.ExitCode === 137) { + // Killed, presumably to run a new preparer. + } else { + // Boom! Something went wrong. + this.reportError(`The ${preparerName} preparer exited with status ${container.State.ExitCode}.`); + } + } + reportError(message) { this.state = "error"; this.error = message;