1.0.5 • Published 2 years ago

@bash-commands/ls v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

ls

ls command from bash ported to node.js

Installation

npm install --save @bash-commands/ls

Usage

const ls = require('@bash-commands/ls');

// .... Your code here ....
async function main() {
  try {
    let result;
    
    // usage with default options
    result = await ls();
    console.log(result);
    // [ 'README.md', 'package.json', 'package-lock.json', 'node_modules', 'dist', 'src', 'index.js' ]

    // usage with custom options
    result = await ls('./', 'file', {
      args: {
        a: true, // equivalent to -a
        l: true, // equivalent to -l
      },
      output_path: './tmp/logs/', // default is './out/'
      arg_prefix: '--', // default is '-'
      arg_suffix: '=', // default is ' '
    });
    console.log(result);
    /** 
      * [
      * 'drwxr-xr-x  15 username  staff   480  7 jan 16:20 .', 
      * 'drwxr-xr-x  15 username  staff   480  7 jan 16:20 ..',
      * '-rw-r--r--  1 username  staff   609  7 jan 16:20 README.md',
      * '-rw-r--r--  1 username  staff   609  7 jan 16:20 package.json',
      * ]
      */
  } catch (err) {
    console.error(err);
  }
}

Configuration (optional)

ParameterTypeDefaultDescription
dirstring./On which directory should ls be executed
output'console'\|'file''console'Should the ls command returns the stdout or should write it to an output file
optionsobject{args: {}, output_path: './out', arg_prefix: '-', arg_suffix: ' '}Configuration for the ls command, like passing args, defining the output path when output === 'file'

License

License: ISC

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago