Skip to content

New: Added support for copying directories #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Options:
Use together '--watch' option.
-p, --preserve The flag to copy attributes of files.
This attributes are uid, gid, atime, and mtime.
-r --directory The Flag to copy directory
-t, --transform <name> A module name to transform each file. cpx lookups
the specified name via "require()".
-u, --update The flag to not overwrite files on destination if
Expand Down
1 change: 1 addition & 0 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const args = subarg(process.argv.slice(2), {
includeEmptyDirs: "include-empty-dirs",
L: "dereference",
p: "preserve",
r: "directory",
t: "transform",
u: "update",
v: "verbose",
Expand Down
1 change: 1 addition & 0 deletions bin/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ module.exports = function main(source, outDir, args) {
transform: mergedTransformFactories,
dereference: args.dereference,
includeEmptyDirs: args.includeEmptyDirs,
directory: args.directory,
initialCopy: args.initial,
preserve: args.preserve,
update: args.update,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/apply-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = function applyAction(pattern, options, action) {
}

const globOptions = {
nodir: !options.includeEmptyDirs,
nodir: !(options.includeEmptyDirs || options.directory),
silent: true,
follow: Boolean(options.dereference),
nosort: true,
Expand Down
1 change: 1 addition & 0 deletions lib/utils/copy-file-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module.exports = function copyFileSync(source, output, options) {

if (stat.isDirectory()) {
fs.ensureDirSync(output)
fs.copySync(source, output)
} else {
fs.ensureDirSync(path.dirname(output))
fs.copySync(source, output)
Expand Down
1 change: 1 addition & 0 deletions lib/utils/copy-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ module.exports = co.wrap(function* copyFile(source, output, options) {

if (stat.isDirectory()) {
yield fs.ensureDir(output)
yield fs.copy(source, output)
} else {
yield fs.ensureDir(path.dirname(output))
yield copyFileContent(source, output, options.transform)
Expand Down
1 change: 1 addition & 0 deletions lib/utils/normalize-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports = function normalizeOptions(source, outputDir, options) {
clean: Boolean(options && options.clean),
dereference: Boolean(options && options.dereference),
includeEmptyDirs: Boolean(options && options.includeEmptyDirs),
directory: Boolean(options && options.directory),
initialCopy: (options && options.initialCopy) !== false,
outputDir,
preserve: Boolean(options && options.preserve),
Expand Down