From db6e36dae09f8e03bfcc27c6e71dc904f06a1de7 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 5 Feb 2025 13:03:11 -0800 Subject: [PATCH] Fix listDir bug returning empty lines --- repl.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/repl.js b/repl.js index 96e43e3..1424d2a 100644 --- a/repl.js +++ b/repl.js @@ -209,19 +209,20 @@ for item in contents: print(item, result[0], result[6], result[9]) `; const result = await this._repl.runCode(code); - let contents = []; if (!result) { return contents; } for (let line of result.split("\n")) { - let [name, isDir, fileSize, fileDate] = line.split(" "); - contents.push({ - path: name, - isDir: isDir == TYPE_DIR, - fileSize: parseInt(fileSize), - fileDate: parseInt(fileDate) * 1000, - }); + if (line.length > 0) { + let [name, isDir, fileSize, fileDate] = line.split(" "); + contents.push({ + path: name, + isDir: isDir == TYPE_DIR, + fileSize: parseInt(fileSize), + fileDate: parseInt(fileDate) * 1000, + }); + } } return contents; }