-
-
Notifications
You must be signed in to change notification settings - Fork 939
Description
Description
I'm trying to embed repomix into a broader application. I'm invoking it as a library, as documented in the README. The only difference is that I'm specifying an absolute path, because I don't want the files created in the current working directory. I may have concurrent requests and so I don't want to risk different requests trying to write to the same directory.
import { runCli, type CliOptions } from 'repomix';
// Clone and process a GitHub repo
async function processRemoteRepo(repoUrl) {
const options = {
remote: repoUrl,
output: '/tmp/my_private_dir/output.xml',
compress: true
} as CliOptions;
return await runCli(['.'], process.cwd(), options);
}This crashes out with an error like
RepomixError: Failed to copy output file: EINVAL: invalid argument, copyfile '/tmp/my_private_dir/output.xml' -> '/tmp/my_private_dir/output.xml'.
Looking at the code, I think the problem is in these lines:
repomix/src/cli/actions/remoteAction.ts
Lines 191 to 192 in 495e4c5
| const sourcePath = path.resolve(sourceDir, outputFileName); | |
| const targetPath = path.resolve(targetDir, outputFileName); |
Because we're passing an absolute path for the filename, both the source and the destination resolve to the same path and the copy has no meaning. Instead, I think we should output the file initially to a static location so that it doesn't need to look at the provided filename to resolve the location. Then we can copy as normal, resolving only the output path.
Usage Context
Repomix CLI
Repomix Version
1.6.0
Node.js Version
bun 1.2.17