Merge pull request #16 from makermelissa/main

Fix listDir bug returning empty lines
This commit is contained in:
Melissa LeBlanc-Williams 2025-02-05 13:04:49 -08:00 committed by GitHub
commit b96e9660ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

17
repl.js
View file

@ -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;
}