Skip to content

Commit

Permalink
feat(cli): start writes to _site-dev and only clears that folder
Browse files Browse the repository at this point in the history
  • Loading branch information
daKmoR committed Aug 20, 2022
1 parent cbfb0f9 commit 39206a1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-jars-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket/cli': patch
---

`rocket start` now outputs to `_site-dev` instead of `_site`.
5 changes: 5 additions & 0 deletions .changeset/heavy-jars-stare2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket/cli': patch
---

`rocket start` clears only its output folder (defaults to `_site-dev`)
3 changes: 2 additions & 1 deletion packages/cli/src/RocketBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ export class RocketBuild {

async build() {
await this.cli.events.dispatchEventDone('build-start');
await this.cli.clearOutputDirs();
await this.cli.clearOutputDir();
await this.cli.clearOutputDevDir();

this.engine = new Engine();
this.engine.setOptions({
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/RocketCli.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,13 @@ export class RocketCli {
}
}

async clearOutputDirs() {
async clearOutputDir() {
if (this.options.outputDir && existsSync(this.options.outputDir)) {
await rm(this.options.outputDir, { recursive: true, force: true });
}
}

async clearOutputDevDir() {
if (this.options.outputDevDir && existsSync(this.options.outputDevDir)) {
await rm(this.options.outputDevDir, { recursive: true, force: true });
}
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/RocketStart.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export class RocketStart {
if (!this.cli) {
return;
}
await this.cli.clearOutputDirs();
await this.cli.clearOutputDevDir();

// TODO: enable URL support in the Engine and remove this "workaround"
if (
typeof this.cli.options.inputDir !== 'string' ||
typeof this.cli.options.outputDir !== 'string'
typeof this.cli.options.outputDevDir !== 'string'
) {
return;
}
Expand All @@ -51,7 +51,7 @@ export class RocketStart {
this.engine = new Engine();
this.engine.setOptions({
docsDir: this.cli.options.inputDir,
outputDir: this.cli.options.outputDir,
outputDir: this.cli.options.outputDevDir,
setupPlugins: this.cli.options.setupEnginePlugins,
open: this.cli.options.open,
longFileHeaderWidth: this.cli.options.longFileHeaderWidth,
Expand Down

0 comments on commit 39206a1

Please sign in to comment.