Skip to content

Commit b96e966

Browse files
authored
Merge pull request #16 from makermelissa/main
Fix listDir bug returning empty lines
2 parents 839ebe2 + db6e36d commit b96e966

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

repl.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,20 @@ for item in contents:
209209
print(item, result[0], result[6], result[9])
210210
`;
211211
const result = await this._repl.runCode(code);
212-
213212
let contents = [];
214213
if (!result) {
215214
return contents;
216215
}
217216
for (let line of result.split("\n")) {
218-
let [name, isDir, fileSize, fileDate] = line.split(" ");
219-
contents.push({
220-
path: name,
221-
isDir: isDir == TYPE_DIR,
222-
fileSize: parseInt(fileSize),
223-
fileDate: parseInt(fileDate) * 1000,
224-
});
217+
if (line.length > 0) {
218+
let [name, isDir, fileSize, fileDate] = line.split(" ");
219+
contents.push({
220+
path: name,
221+
isDir: isDir == TYPE_DIR,
222+
fileSize: parseInt(fileSize),
223+
fileDate: parseInt(fileDate) * 1000,
224+
});
225+
}
225226
}
226227
return contents;
227228
}

0 commit comments

Comments
 (0)