CliSite/commands/ls.ts

20 lines
544 B
TypeScript
Raw Normal View History

2022-06-12 09:38:38 +02:00
function ls(curdir:any):string {
var buf = "";
buf += "Files in the current directory:\n";
//list only first level files
for (var key in curdir) {
//buf += key + "\n";
//also print if it is a directory or file
if (typeof curdir[key] == "string") {
buf += key + " (file)\n";
}
else if (typeof curdir[key] == "object") {
buf += key + " (directory)\n";
}
else {
buf += key + " (unknown)\n";
}
}
return buf;
}
export { ls };