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

misc(build): ensure distDir is present before emptying it #12829

Merged
merged 3 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build/build-dt-report-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ function writeFile(name, content) {
fs.writeFileSync(`${distDir}/${name}`, content);
}

fs.mkdirSync(distDir, {recursive: true}); // Ensure dist is present, else rmdir will throw
fs.rmdirSync(distDir, {recursive: true});
fs.mkdirSync(distDir);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead we can use fs.rmSync with force: true and recursive: true.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm/rmSync aren't supported until Node 14

Copy link
Member Author

@paulirish paulirish Jul 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rmSync is new in node 14. (not in 12). :/

fsPromises.rmdir has force, but will require a bigger diff in this file. jk, my mistake. need the rm method in sync or promises versions. both need node 14.

fs.mkdirSync(distDir, {recursive: true});

writeFile('report.js', htmlReportAssets.REPORT_JAVASCRIPT);
writeFile('report.css', htmlReportAssets.REPORT_CSS);
Expand Down
1 change: 1 addition & 0 deletions build/gh-pages-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class GhPagesApp {
}

async build() {
fs.mkdirSync(this.distDir, {recursive: true}); // Ensure dist is present, else rmdir will throw
fs.rmdirSync(this.distDir, {recursive: true});

const html = this._compileHtml();
Expand Down