Skip to content
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

Error: Cannot delete files/directories outside the current working directory #144

Open
arepp23 opened this issue Jul 17, 2022 · 1 comment

Comments

@arepp23
Copy link

arepp23 commented Jul 17, 2022

I am trying to delete all the files (but not the directories) in a nested directory structure.

Here's my code

                let resourcePath = path.join(configDir, "projects", this.projectName, "source", '**','*.*');
                resourcePath = resourcePath.replace(/\\/g, '/');
                const deletedFilePaths = await del([resourcePath]);

resourcePath will console.log as C:/Users/username/AppData/Roaming/mf/projects/empty/source/**/*.*

This throws the following:

UnhandledPromiseRejectionWarning: Error: Cannot delete files/directories outside the current working directory. Can be overridden with the force option.

I'm not sure if there's a way to specify a relative folder location and then the glob pattern separately to avoid this?

@yisibl
Copy link

yisibl commented Apr 13, 2023

try

await del([resourcePath], { force: true });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants