0.0.7 • Published 11 months ago

cpdirplus v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

cpdirplus

cpdirplus mean richer copy functions.

Installation

# npm
npm install cpdirplus --save-dev
# yarn
yarn add cpdirplus --save-dev
# pnpm
pnpm add cpdirplus --save-dev

Usage

basic

copy ./dist to ./build/productionDist

cpdirplus({
    from: path.join(__dirname, "dist"),
    to: path.join(__dirname, "build/productionDist"),
})

command line

just copy

cpdirplus ./dist ./build/productionDist
cpdirplus -f ./dist -t ./build/productionDist
cpdirplus --from ./dist --to ./build/productionDist

remove - delete source after copy.

cpdirplus ./dist ./build/productionDist -m

base

cpdirplus "**/*js" ./build/productionDist -b dist

renameFiles

rename then file. base path is from field.

cpdirplus({
  from: path.join(__dirname, 'dist'),
  to: path.join(__dirname, 'build/productionDist'),
  renameFiles: { _gitignore: '.gitignore' },
});

replacements

%PORJECTNAME% to replace with a CopyDirectory string in the README.md file.

// dist/README.md
xxxxx%PORJECTNAME%xxxxx
    🔽
// build/productionDist/README.md
xxxxxCopyDirectoryxxxxx
cpdirplus({
  from: path.join(__dirname, 'dist'),
  to: path.join(__dirname, 'build/productionDist'),
  replacements: [{ filename: 'README.md', PORJECTNAME: 'CopyDirectory' }],
});

test

Use a regular approach.

All js file under the from path.

cpdirplus({
    test: /\.js$/
    from: path.join(__dirname, "dist"),
    to: path.join(__dirname, "build/productionDist"),
})

include

Using the globs rule.

All ts files in the src directory will be included.

cpdirplus({
    include: ["src/*.ts"]
    from: path.join(__dirname, "dist"),
    to: path.join(__dirname, "build/productionDist"),
})

exclude

Using the globs rule.

Exclude all css files under dist.

cpdirplus({
    exclude: ["dist/*.css"]
    from: path.join(__dirname, "dist"),
    to: path.join(__dirname, "build/productionDist"),
})

move

Whether to delete the source.

just move the source.

cpdirplus({
  move: true, // default false
  from: path.join(__dirname, 'dist'),
  to: path.join(__dirname, 'build/productionDist'),
});

Options

nametypedefaultdescriptionrequired
fromstring-source pathtrue
tostring-target pathtrue
testRegex-match filefalse
includeRegex-match filefalse
excludeRegex-match filefalse
renameFilesstring[]-rename filefalse
movebooleanfalseremove sourcefalse
replacementsReplacementOption[]-magic field - %Public%false
0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago