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

fix: Make sure the directory exists before trying to copy files to it #1

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

halkeye
Copy link

@halkeye halkeye commented Oct 2, 2021

Surround the copy with mkdirp
switch console.log to reporter

@halkeye
Copy link
Author

halkeye commented Oct 2, 2021

okay i decided to not use the plugin, its easy enough to just do the folowing onCreateNode

  if (node.internal.type === 'File') {
    if (node.sourceInstanceName === 'images') {
      const dir = path.join(__dirname, 'public', 'images', node.relativeDirectory);
      await fs.promises.mkdir(dir, { recursive: true });
      await fs.promises.copyFile(node.absolutePath, path.join(dir, node.base));
    }
  }

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

Successfully merging this pull request may close these issues.

1 participant