Skip to content

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

@arepp23

Description

@arepp23

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions