freeCodeCamp / freeCodeCampOS

Test repo for external freeCodeCamp courses

Home Page:https://opensource.freecodecamp.org/freeCodeCampOS/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

seed should be relative to current project

ShaunSHamilton opened this issue · comments

seed.js needs some refactoring, and a part of that is fixing the pathing for filesWithSeed to be relative to the current project:

### --seed--

#### --"in-project-dir.js"--

If a file in root needs to be seeded, then:

#### --"../in-root-dir.js"--

This is a breaking change for #262

I might be looking at wrong thing, but isn't this already a case?

As a test I added seed to the root with #### --"../file.js"-- to one of the projects in the near curriculum. File was then seeded in the root.

@gikf We currently do not do any path adjusting:

await runSeedDeprecated(filesWithSeed);

for (const [filePath, fileSeed] of filesWithSeed) {
const filePathWithRoot = `${filePath}`;
await writeFile(filePathWithRoot, fileSeed);

Yes, but that still appears to write to correct path...

Following the example with ../file.js. filePathWithRoot and filePath are the same, relative path - ../file.js

They are definitely not the same. filePathWithRoot and filePath are exactly the same, yes, but that is why the logic is incorrect. How are you testing this?

Oh, sorry, of course I was looking at the wrong thing. It is seeded, but not in the right path. 🤦‍♂️

If you don't mind I'd use this occasion to replace usage of runSeedDeprecated (along runCommands) in seedLesson with runLessonSeed.

If you don't mind I'd use this occasion to replace...

👇

seed.js needs some refactoring

Actually. I have changed my mind about this.

Often, the seed requires something outside of the current project dir to change. So, this should remain relative to ROOT.