Skip to content

Commit c4ef46a

Browse files
authored
Fix missing yo-rc.json error (#57)
1 parent d97c5f3 commit c4ef46a

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ Install [Poetry](https://python-poetry.org) to manage your dependencies and tool
5252

5353
### Node.js
5454

55-
Install a stable version of [Node.js](https://nodejs.org/) (v16.x.x) if you don't have one.
55+
Install a stable version of [Node.js](https://nodejs.org/) (v18.x.x) if you don't have one.
5656
The Sicarator is indeed a [Yeoman](https://yeoman.io/) generator, which is a `Node.js` module.
5757

5858
For linux:
5959
```bash
60-
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
60+
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
6161
sudo apt-get install -y nodejs
6262
```
6363

generators/app/index.js

+27-19
Original file line numberDiff line numberDiff line change
@@ -317,16 +317,6 @@ module.exports = class extends Generator {
317317
this.log(`${chalk.green("create folder")} ${this.answers.projectSlug}`);
318318
mkdirp.sync(this.answers.projectSlug);
319319
this.destinationRoot(this.destinationPath(this.answers.projectSlug));
320-
321-
// A ".yo-rc.json" file may have been created at the starting path during the prompting step
322-
if (
323-
this.fs.exists(this.destinationPath(path.join("..", ".yo-rc.json")))
324-
) {
325-
this.fs.move(
326-
this.destinationPath(path.join("..", ".yo-rc.json")),
327-
this.destinationPath(".yo-rc.json")
328-
);
329-
}
330320
}
331321
}
332322

@@ -434,23 +424,41 @@ module.exports = class extends Generator {
434424
}
435425

436426
end() {
427+
// The ".yo-rc.json" file may have been created at the starting path during the prompting step and has to be moved
428+
// to the generated project folder. It should be moved in the `end()` step because previous steps may use the
429+
// ".yo-rc.json" file in its original path.
430+
if (
431+
!this.fs.exists(this.destinationPath(".yo-rc.json")) &&
432+
this.fs.exists(this.destinationPath(path.join("..", ".yo-rc.json")))
433+
) {
434+
this.fs.move(
435+
this.destinationPath(path.join("..", ".yo-rc.json")),
436+
this.destinationPath(".yo-rc.json")
437+
);
438+
}
439+
437440
// Initialize git repository
438441
this.spawnCommandSync("git", ["init"]);
439442

440-
// Create initial commit if there is no commit yet
443+
// If there is no commit yet, add all files to Git and create initial commit
441444
if (
442445
this.spawnCommandSync("git", ["rev-parse", "--verify", "HEAD"], {
443446
stdio: "ignore"
444447
}).status !== 0
445448
) {
446-
this.spawnCommandSync("git", ["add", "."]);
447-
this.log("Creating initial commit");
448-
this.spawnCommandSync("git", [
449-
"commit",
450-
"--quiet",
451-
"--message",
452-
"Initial commit (generated by Sicarator)"
453-
]);
449+
// Commit last file system changes (especially ".yo-rc.json" move) so that everything is added to Git
450+
this.fs.commit([], () => {
451+
this.log("Adding all generated files to Git");
452+
this.spawnCommandSync("git", ["add", "."]);
453+
454+
this.log("Creating initial commit");
455+
this.spawnCommandSync("git", [
456+
"commit",
457+
"--quiet",
458+
"--message",
459+
"Initial commit (generated by Sicarator)"
460+
]);
461+
});
454462
}
455463
}
456464
};

0 commit comments

Comments
 (0)