0.0.7 • Published 1 year ago
cpdirplus v0.0.7
cpdirplus
cpdirplus mean richer copy functions.
Installation
# npm
npm install cpdirplus --save-dev
# yarn
yarn add cpdirplus --save-dev
# pnpm
pnpm add cpdirplus --save-devUsage
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/productionDistcpdirplus -f ./dist -t ./build/productionDistcpdirplus --from ./dist --to ./build/productionDistremove - delete source after copy.
cpdirplus ./dist ./build/productionDist -mbase
cpdirplus "**/*js" ./build/productionDist -b distrenameFiles
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
xxxxxCopyDirectoryxxxxxcpdirplus({
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
| name | type | default | description | required |
|---|---|---|---|---|
| from | string | - | source path | true |
| to | string | - | target path | true |
| test | Regex | - | match file | false |
| include | Regex | - | match file | false |
| exclude | Regex | - | match file | false |
| renameFiles | string[] | - | rename file | false |
| move | boolean | false | remove source | false |
| replacements | ReplacementOption[] | - | magic field - %Public% | false |