Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

output-files

dword-design3.1kMIT2.0.32

Output a tree of files and directories by providing an object. Especially useful for testing with real files.

build, create, declarative, directory, file, files-system, fs, generate, json, object, recursive, test, tree, write

readme

output-files

npm version Linux macOS Windows compatible Build status Coverage status Dependency status Renovate enabled
Open in Gitpod Buy Me a Coffee PayPal Patreon

Output a tree of files and directories by providing an object. Especially useful for testing with real files.

Install

# npm
$ npm install output-files

# Yarn
$ yarn add output-files

Usage

const outputFiles = require('output-files')

// outputs files in process.cwd()
await outputFiles({
  'example1.md': 'Donec id elit non mi porta gravida at eget.',
  'example2.md': 'Aenean eu leo quam. Pellentesque ornare.',
  someFolder: {
    'content.md': 'Vivamus sagittis lacus vel augue laoreet.',
    'README.md': '# This needs to be filled',
  },
})

// outputs files in example subdirectory
await outputFiles('example', {
  'foo.md': 'This is an interesting file',
  'example2.md': 'This is another interesting file',
})

// you can also define subdirectories without nesting the object
await outputFiles({
  'folder1/folder2': {
    'foo.md': 'This is an interesting file',
  },
  'foo/bar/example2.md': 'This is another interesting file',
})

Contribute

Are you missing something or want to contribute? Feel free to file an issue or a pull request! ⚙️

Support

Hey, I am Sebastian Landwehr, a freelance web developer, and I love developing web apps and open source packages. If you want to support me so that I can keep packages up to date and build more helpful tools, you can donate here:

Buy Me a Coffee  If you want to send me a one time donation. The coffee is pretty good 😊.
PayPal  Also for one time donations if you like PayPal.
Patreon  Here you can support me regularly, which is great so I can steadily work on projects.

Thanks a lot for your support! ❤️

See also

  • with-local-tmp-dir: Creates a temporary folder inside cwd, cds inside the folder, runs a function, and removes the folder. Especially useful for testing.
  • expect-mocha-image-snapshot: A wrapper around jest-image-snapshot that makes it compatible to Mocha.
  • jest-image-matcher: A Jest matcher for image comparisons based on pixelmatch. Can also be used with Mocha. Useful for visual regression testing.
  • unify-mocha-output: Adjusts a Mocha output so that it is consistent across platforms and can be used for snapshot testing. Basically adjusts the checkmark symbol and removes time values.
  • mock-argv: Temporarily overrides the command line arguments. This is useful for testing.

License

MIT License © Sebastian Landwehr

changelog

2.0.32 (2023-11-28)

Bug Fixes

  • update dependency fs-extra to v11.2.0 (088fd49)

2.0.31 (2023-07-06)

Bug Fixes

  • update dependency globby to v13.2.2 (739cd5e)

2.0.30 (2023-07-01)

Bug Fixes

  • update dependency globby to v13.2.1 (3788f5a)

2.0.29 (2023-06-18)

Bug Fixes

  • update dependency globby to v13.2.0 (1261c70)

2.0.28 (2023-05-13)

Bug Fixes

  • update dependency @dword-design/tester to v2.0.19 (161015b)

2.0.27 (2023-04-11)

Bug Fixes

  • update dependency globby to v13.1.4 (8a7e62c)

2.0.26 (2023-04-11)

Bug Fixes

  • update dependency @dword-design/tester-plugin-tmp-dir to v2.1.26 (2201db4)

2.0.25 (2023-04-11)

Bug Fixes

  • update dependency @dword-design/tester-plugin-tmp-dir to v2.1.24 (e143332)

2.0.24 (2023-04-11)

Bug Fixes

  • update dependency @dword-design/tester to v2.0.18 (ac7836e)

2.0.23 (2023-04-10)

Bug Fixes

  • update dependency @dword-design/tester to v2.0.16 (aa806a4)

2.0.22 (2023-04-10)

Bug Fixes

  • update dependency @dword-design/tester-plugin-tmp-dir to v2.1.21 (8ec45d8)

2.0.21 (2023-04-09)

Bug Fixes

  • update dependency @dword-design/functions to v4.1.7 (c21e6ab)

2.0.20 (2023-04-09)

Bug Fixes

  • update dependency @dword-design/tester to v2.0.14 (07a3b69)
  • update dependency @dword-design/tester-plugin-tmp-dir to v2.1.19 (656fc36)

2.0.19 (2023-03-20)

Bug Fixes

  • update dependency @dword-design/tester-plugin-tmp-dir to v2.1.18 (c0101a8)
  • update dependency fs-extra to v11.1.1 (d3b3904)

2.0.18 (2023-03-19)

Bug Fixes

  • update dependency @dword-design/tester-plugin-tmp-dir to v2.1.17 (458c3a9)

2.0.17 (2023-03-19)

Bug Fixes

  • update dependency @dword-design/tester-plugin-tmp-dir to v2.1.16 (9f6cd49)

2.0.16 (2023-03-19)

Bug Fixes

  • update dependency @dword-design/tester-plugin-tmp-dir to v2.1.15 (171bab1)

2.0.15 (2023-03-18)

Bug Fixes

  • update dependency @dword-design/tester-plugin-tmp-dir to v2.1.14 (6c6de81)

2.0.14 (2023-03-18)

Bug Fixes

  • update dependency @dword-design/tester-plugin-tmp-dir to v2.1.13 (e01061f)

2.0.13 (2023-03-16)

Bug Fixes

  • update dependency @dword-design/tester-plugin-tmp-dir to v2.1.12 (d25bce7)

2.0.12 (2023-03-15)

Bug Fixes

  • update dependency @dword-design/tester-plugin-tmp-dir to v2.1.10 (e5705e4)

2.0.11 (2023-02-15)

Bug Fixes

2.0.10 (2022-01-12)

Bug Fixes

2.0.9 (2022-01-04)

Bug Fixes

2.0.8 (2021-07-20)

Bug Fixes

2.0.7 (2021-07-06)

Bug Fixes

2.0.6 (2021-06-29)

Bug Fixes

2.0.5 (2021-06-14)

Bug Fixes

2.0.4 (2021-05-28)

Bug Fixes

2.0.3 (2021-05-04)

Bug Fixes

  • update dependency fs-extra to v10 (#46) (fe57cdf)

2.0.2 (2021-05-04)

Bug Fixes

  • update dependency with-local-tmp-dir to v4 (#47) (ce1bbd6)

2.0.1 (2021-05-03)

Bug Fixes

  • update dependency @dword-design/functions to v4 (#45) (af01fa2)

2.0.0 (2021-05-03)

Bug Fixes

  • update dependency @dword-design/base to v8 (#44) (b2cca9d)

BREAKING CHANGES

  • require Node.js >= 12

Co-authored-by: Renovate Bot bot@renovateapp.com Co-authored-by: Sebastian Landwehr info@dword-design.de Co-authored-by: GitHub Actions actions@github.com

1.1.27 (2021-04-26)

Bug Fixes

  • update dependency with-local-tmp-dir to v3 (#41) (b240670)

1.1.26 (2021-04-20)

Bug Fixes

1.1.25 (2021-04-12)

Bug Fixes

1.1.24 (2021-03-31)

Bug Fixes

1.1.23 (2021-03-23)

Bug Fixes

  • update dependency @dword-design/functions to v3 (#33) (2ef82e2)

1.1.22 (2021-03-22)

Bug Fixes

1.1.21 (2021-03-17)

Bug Fixes

1.1.20 (2021-02-17)

Bug Fixes

1.1.19 (2020-12-02)

Bug Fixes

  • config: Update changed files (28b227f)

1.1.18 (2020-08-26)

Bug Fixes

1.1.17 (2020-07-04)

Bug Fixes

1.1.16 (2020-03-19)

Bug Fixes

  • deps: update dependency fs-extra to v9 (f5cce7f)

1.1.15 (2020-02-18)

Bug Fixes

1.0.0 (2020-02-18)

Bug Fixes