@cloud411716/fancy-webnovel 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -149,10 +149,17 @@ function spawnScraper(script, extraArgs, outDir) {
|
|
|
149
149
|
let out = '';
|
|
150
150
|
p.stdout.on('data', d => { out += d.toString(); });
|
|
151
151
|
p.on('close', (code) => {
|
|
152
|
-
|
|
152
|
+
const outTrimmed = out.trim();
|
|
153
|
+
// scraper 内部吞掉了很多错误(返回 null 但 exit 0),通过 stdout 里的失败标识判断
|
|
154
|
+
const softFail = outTrimmed.includes('已跳过') ||
|
|
155
|
+
outTrimmed.includes('采集失败') ||
|
|
156
|
+
outTrimmed.includes('✗') ||
|
|
157
|
+
outTrimmed.includes('failed');
|
|
158
|
+
if (code === 0 && !softFail && outTrimmed) {
|
|
153
159
|
resolve({ ok: true, output: out });
|
|
154
160
|
} else {
|
|
155
|
-
|
|
161
|
+
// 把 stdout 末 500 字符当错误摘要
|
|
162
|
+
resolve({ ok: false, output: out, error: outTrimmed.slice(-500) || `exit ${code}` });
|
|
156
163
|
}
|
|
157
164
|
});
|
|
158
165
|
p.on('error', e => resolve({ ok: false, output: '', error: e.message }));
|