@zhangfuxing/readdir
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

readdir

Get the absolute path of files in a folder

Install

$ npm i @zhangfuxing/readdir

Useage

use synchronous method

const assert = require('assert');
const path = require('path');
const { getFilePathsSync } = require('@zhangfuxing/readdir');
const paths = getFilePathsSync('./test');
const testFilePath = path.resolve('./test/index.test.js');
assert(paths);
assert(Array.isArray(paths));
assert(paths.length === 1);
assert(paths[0] === testFilePath);

use asynchronous method

const assert = require('assert');
const path = require('path');
const { getFilePaths } = require('@zhangfuxing/readdir');
const testFilePath = path.resolve('./test/index.test.js');

;(async () => {
  const paths = await getFilePaths('./test');
  assert(paths);
  assert(Array.isArray(paths));
  assert(paths.length === 1);
  assert(paths[0] === testFilePath);
})().catch(console.error);

Test

$ npm test

Package Sidebar

Install

npm i @zhangfuxing/readdir

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

4.11 kB

Total Files

5

Last publish

Collaborators

  • fuxingzhang