@cygraw/cowpea
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

Cowpea

import cp from 'cowpea'

// copy `./from/foo.js` to directory `./dest` as `./dest/foo.js`
cp.from('./from').to('./dest').copy('foo.js')

// or copy the content and change the file name
cp.from('./from').to('./dest').copy('foo.js', { dest: 'bar.js' })

// you can also process the file content
cp.from('./from')
  .to('./dest')
  .copy('foo.js', {
    dest: 'bar.js',
    processor: (content) => 'new content\n' + content,
  })

// copy the whole directory to a new place
cp.from('./from')
  .to('./dest')
  .copyDirectory({
    /**
     * to filter files in the directory
     * return new file name
     * or return null to skip this file
     */
    filter: (fileName) => {
      if (/** some logic here */ fileName) return `newFileName`
      return null
    },
    /** return processed content to be wirtten in the new file */
    processor: (content) => 'new content\n' + content,
  })

Readme

Keywords

Package Sidebar

Install

npm i @cygraw/cowpea

Weekly Downloads

4

Version

0.2.1

License

ISC

Unpacked Size

5.06 kB

Total Files

7

Last publish

Collaborators

  • cygraw