Skip to content

Commit 2b981ed

Browse files
committed
collapsed getuserargs function
1 parent 14d4d33 commit 2b981ed

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

  • implement-shell-tools/ls

‎implement-shell-tools/ls/ls.js‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,18 @@ ls(process.argv);
1414
// ----------
1515

1616
function ls(args) {
17-
const userArgs = getUserArgs(args);
18-
const currentWorkingDirectory = getCurrentWorkingDirectory(args);
19-
const fsItems = checkArgsLength(getFsItems(userArgs));
17+
const userArgs = args.slice(2);
2018

2119
executeFlags(getFlags(userArgs));
2220

21+
const fsItems = checkArgsLength(getFsItems(userArgs));
22+
const currentWorkingDirectory = getCurrentWorkingDirectory(args);
2323
const dirArgs = getDirArgs(fsItems, currentWorkingDirectory);
2424
const fileArgs = getFileArgs(fsItems, currentWorkingDirectory);
2525

2626
print(populateOutput(fsItems, dirArgs, fileArgs, currentWorkingDirectory));
2727
}
2828

29-
function getUserArgs(args) {
30-
return args.slice(2);
31-
}
32-
3329
function getFsItems(userArgs) {
3430
return userArgs.filter((arg) => !arg.startsWith("-"));
3531
}

0 commit comments

Comments
 (0)