node-git-hooks icon indicating copy to clipboard operation
node-git-hooks copied to clipboard

Fix copying directories

Open CommanderRedYT opened this issue 1 year ago • 5 comments

CommanderRedYT avatar Jun 05 '24 10:06 CommanderRedYT

cpSync is still experimental.

Can you provide some context of what you are trying to do?

The current code loops through the given dir and copies files and dirs when needed,.

Harm-Nullix avatar Jun 05 '24 11:06 Harm-Nullix

I have a folder called githooks. There is a folder called pre-commit.d with multiple scripts inside. Then, there is a script called pre-commit which iterates over all the scripts in the directory in order.

When I use this script, I get an error for copying the first file inside the pre-commit.d directory after the script tried to create the folder. (Added some logging to confirm that)

CommanderRedYT avatar Jun 05 '24 12:06 CommanderRedYT

Also: https://github.com/nodejs/node/pull/53127

CommanderRedYT avatar Jun 05 '24 13:06 CommanderRedYT

Interessting, curious about that output.

Also, it should make more sense then, if cp just copies both folder and files, to replace the copyDir fn on line https://github.com/peacechen/node-git-hooks/pull/7/files#diff-8e53cb956f4b0661996bd517a983cd87fc5ccd2374a7e1eb4bcd9479877ac86eL33 instead of clouding up a child function with cp.

Harm-Nullix avatar Jun 05 '24 19:06 Harm-Nullix

Installing Git hooks...
Error copying Git hooks:  Error: ENOENT: no such file or directory, copyfile '.githooks/pre-commit.d/check-for-unresolved-conflicts' -> '.git/hooks/pre-commit.d/check-for-unresolved-conflicts'
    at Object.copyFileSync (node:fs:2993:3)
    at copy (/home/ccomm/Dokumente/opendtu-react-native/node_modules/node-git-hooks/install-git-hooks.js:57:6)
    at copyDir (/home/ccomm/Dokumente/opendtu-react-native/node_modules/node-git-hooks/install-git-hooks.js:51:7)
    at copyDir (/home/ccomm/Dokumente/opendtu-react-native/node_modules/node-git-hooks/install-git-hooks.js:46:7)
    at installGitHooks (/home/ccomm/Dokumente/opendtu-react-native/node_modules/node-git-hooks/install-git-hooks.js:33:5)
    at Object.<anonymous> (/home/ccomm/Dokumente/opendtu-react-native/node_modules/node-git-hooks/bin/install.js:5:8)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12) {
  errno: -2,
  syscall: 'copyfile',
  code: 'ENOENT',
  path: '.githooks/pre-commit.d/check-for-unresolved-conflicts',
  dest: '.git/hooks/pre-commit.d/check-for-unresolved-conflicts'
}

It works fine after I run mkdir .git/hooks/pre-commit.d

CommanderRedYT avatar Jun 08 '24 12:06 CommanderRedYT