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

Babel removes test files from src directory after building #163

Open
MichaelDeBoey opened this issue Oct 21, 2020 · 1 comment
Open

Babel removes test files from src directory after building #163

MichaelDeBoey opened this issue Oct 21, 2020 · 1 comment

Comments

@MichaelDeBoey
Copy link
Contributor

  • kcd-scripts version: 6.6.0
  • node version: 14.14.0
  • npm version: 6.14.8

Relevant code or config

$ kcd-scripts build --out-dir .

What you did:
Run npm run build in the root of the project

What happened:
src/__tests__/gatsby-node.js was deleted

Reproduction repository:
https://github.com/MichaelDeBoey/gatsby-plugin-pinterest/tree/support-pluginOptionsSchema

Problem description:
When implementing gatsby-uc/gatsby-plugin-pinterest#15 and running npm run build or npm run validate in the root of the project, src/__tests__/gatsby-node.js was deleted.

Suggested solution:
Investigation needed 🤔

@kentcdodds
Copy link
Owner

I'm guessing it's an issue with this code:

// because babel will copy even ignored files, we need to remove the ignored files
const pathToOutDir = fromRoot(parsedArgs.outDir || builtInOutDir)
const ignoredPatterns = (parsedArgs.ignore || builtInIgnore)
.split(',')
.map(pattern => path.join(pathToOutDir, pattern))
const ignoredFiles = ignoredPatterns.reduce(
(all, pattern) => [...all, ...glob.sync(pattern)],
[],
)
ignoredFiles.forEach(ignoredFile => {
rimraf.sync(ignoredFile)
})

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