Skip to content
This repository has been archived by the owner on Sep 17, 2020. It is now read-only.

Commit

Permalink
Add stderr to debug feedback
Browse files Browse the repository at this point in the history
- Check for search text before clearing
  • Loading branch information
m4rk3r committed Jan 30, 2018
1 parent 463cbb1 commit 0d9bb63
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
14 changes: 9 additions & 5 deletions app/containers/Indexing/Indexing.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class Indexing extends Component {
static propTypes = {
host: PropTypes.string,
dispatch: PropTypes.func,
searchBookmarks: PropTypes.func
searchBookmarks: PropTypes.func,
searchText: PropTypes.string
}

constructor(props) {
Expand All @@ -31,11 +32,13 @@ class Indexing extends Component {
}

componentWillMount() {
const { dispatch, searchBookmarks } = this.props;
const { dispatch, searchBookmarks, searchText } = this.props;
dispatch(clearColl());

// clear search
dispatch(searchBookmarks(''));
if (searchText) {
dispatch(searchBookmarks(''));
}
}

componentDidMount() {
Expand Down Expand Up @@ -83,9 +86,10 @@ class Indexing extends Component {
}
}

const mapStateToProps = ({ app }) => {
const mapStateToProps = ({ search, app }) => {
return {
host: app.getIn(['appSettings', 'host'])
host: app.getIn(['appSettings', 'host']),
searchText: search.bookmarks.text
};
};

Expand Down
28 changes: 20 additions & 8 deletions app/main.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ let mainWindow = null;
let pluginName;
let spawnOptions;
let webrecorderProcess;
let stdoutDebug = [];
let debugOutput = [];

const projectDir = path.join(__dirname, '../');
const stdio = ['ignore', 'pipe', 'ignore'];
const stdio = ['ignore', 'pipe', 'pipe'];
const wrConfig = {};
const pluginDir = 'plugins';

Expand Down Expand Up @@ -71,7 +71,7 @@ const registerOpenWarc = function () {

ipcMain.on('open-warc', (event, argument) => {
const warc = argument;
stdoutDebug = [];
debugOutput = [];
console.log(`warc file: ${warc}`);

// notify renderer that we are initializing webrecorder binary
Expand All @@ -96,17 +96,29 @@ const registerOpenWarc = function () {

// catch any errors spawning webrecorder binary and add to debug info
webrecorderProcess.on('error', (err) => {
stdoutDebug.push(`Error spawning ${webrecorder} binary:\n ${err}\n\n`);
debugOutput.push(`Error spawning ${webrecorder} binary:\n ${err}\n\n`);
});

// log any stderr notices
webrecorderProcess.stderr.on('data', (buff) => {
debugOutput.push(`stderr: ${buff.toString()}`);

// clip line buffer
if (debugOutput.length > 500) {
debugOutput.shift();
}
});

let port;

const findPort = function (rawBuff) {
const buff = rawBuff.toString();

stdoutDebug.push(buff);
if (stdoutDebug.length > 500) {
stdoutDebug.shift();
debugOutput.push(buff);

// clip line buffer
if (debugOutput.length > 500) {
debugOutput.shift();
}

if (!buff || port) {
Expand Down Expand Up @@ -239,5 +251,5 @@ app.on('ready', async () => {
ipcMain.on('async-call', (evt, arg) => {
evt.sender.send('async-response', {
config: wrConfig,
stdout: stdoutDebug.join('<BR>').replace(/\n/g, '<BR>') });
stdout: debugOutput.join('<BR>').replace(/\n/g, '<BR>') });
});

0 comments on commit 0d9bb63

Please sign in to comment.