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

Commit 0d9bb63

Browse files
committed
Add stderr to debug feedback
- Check for search text before clearing
1 parent 463cbb1 commit 0d9bb63

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

app/containers/Indexing/Indexing.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class Indexing extends Component {
1818
static propTypes = {
1919
host: PropTypes.string,
2020
dispatch: PropTypes.func,
21-
searchBookmarks: PropTypes.func
21+
searchBookmarks: PropTypes.func,
22+
searchText: PropTypes.string
2223
}
2324

2425
constructor(props) {
@@ -31,11 +32,13 @@ class Indexing extends Component {
3132
}
3233

3334
componentWillMount() {
34-
const { dispatch, searchBookmarks } = this.props;
35+
const { dispatch, searchBookmarks, searchText } = this.props;
3536
dispatch(clearColl());
3637

3738
// clear search
38-
dispatch(searchBookmarks(''));
39+
if (searchText) {
40+
dispatch(searchBookmarks(''));
41+
}
3942
}
4043

4144
componentDidMount() {
@@ -83,9 +86,10 @@ class Indexing extends Component {
8386
}
8487
}
8588

86-
const mapStateToProps = ({ app }) => {
89+
const mapStateToProps = ({ search, app }) => {
8790
return {
88-
host: app.getIn(['appSettings', 'host'])
91+
host: app.getIn(['appSettings', 'host']),
92+
searchText: search.bookmarks.text
8993
};
9094
};
9195

app/main.dev.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ let mainWindow = null;
2424
let pluginName;
2525
let spawnOptions;
2626
let webrecorderProcess;
27-
let stdoutDebug = [];
27+
let debugOutput = [];
2828

2929
const projectDir = path.join(__dirname, '../');
30-
const stdio = ['ignore', 'pipe', 'ignore'];
30+
const stdio = ['ignore', 'pipe', 'pipe'];
3131
const wrConfig = {};
3232
const pluginDir = 'plugins';
3333

@@ -71,7 +71,7 @@ const registerOpenWarc = function () {
7171

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

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

9797
// catch any errors spawning webrecorder binary and add to debug info
9898
webrecorderProcess.on('error', (err) => {
99-
stdoutDebug.push(`Error spawning ${webrecorder} binary:\n ${err}\n\n`);
99+
debugOutput.push(`Error spawning ${webrecorder} binary:\n ${err}\n\n`);
100+
});
101+
102+
// log any stderr notices
103+
webrecorderProcess.stderr.on('data', (buff) => {
104+
debugOutput.push(`stderr: ${buff.toString()}`);
105+
106+
// clip line buffer
107+
if (debugOutput.length > 500) {
108+
debugOutput.shift();
109+
}
100110
});
101111

102112
let port;
103113

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

107-
stdoutDebug.push(buff);
108-
if (stdoutDebug.length > 500) {
109-
stdoutDebug.shift();
117+
debugOutput.push(buff);
118+
119+
// clip line buffer
120+
if (debugOutput.length > 500) {
121+
debugOutput.shift();
110122
}
111123

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

0 commit comments

Comments
 (0)