Skip to content

Commit

Permalink
Added ln, other commands use lstat
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Oct 14, 2024
1 parent 948bf7a commit 8ec9648
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
10 changes: 10 additions & 0 deletions commands/ln.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// <reference file="./lib.d.ts" >

// Argument parsing
const positionals = args.filter(arg => !arg.startsWith('-')).slice(1);

if (positionals.length != 2) {
throw 'Usage: ln [OPTION]... TARGET LINK_NAME';
}

(args.includes('-s') ? fs.symlinkSync : fs.linkSync)(positionals[0], positionals[1]);
2 changes: 1 addition & 1 deletion commands/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ if (shortFormat) {
}

for (const file of files) {
const stats = fs.statSync(path.join(target, file));
const stats = fs.lstatSync(path.join(target, file));

let colorize = chalk;
for (const [mask, color] of colors) {
Expand Down
3 changes: 1 addition & 2 deletions commands/stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ const types = {

const filePath = args[1] || path.resolve('.') || '/';

// Retrieve the file statistics
const stats = fs.statSync(filePath);
const stats = fs.lstatSync(filePath);

// Write the output to the terminal
terminal.write(`
Expand Down

0 comments on commit 8ec9648

Please sign in to comment.