Skip to content

Commit

Permalink
fix: Check if directory exists, before compressing (#3179)
Browse files Browse the repository at this point in the history
* Check if directory exists, before compressing

* Added changeset
  • Loading branch information
bjon authored Jan 2, 2022
1 parent 943835f commit 7d2b728
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tiny-horses-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-node': patch
---

Check if directory exists, before compressing
6 changes: 5 additions & 1 deletion packages/adapter-node/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createReadStream, createWriteStream, statSync, writeFileSync } from 'fs';
import { createReadStream, createWriteStream, existsSync, statSync, writeFileSync } from 'fs';
import { pipeline } from 'stream';
import glob from 'tiny-glob';
import { fileURLToPath } from 'url';
Expand Down Expand Up @@ -62,6 +62,10 @@ export default function ({
* @param {string} directory
*/
async function compress(directory) {
if (!existsSync(directory)) {
return;
}

const files = await glob('**/*.{html,js,json,css,svg,xml}', {
cwd: directory,
dot: true,
Expand Down

0 comments on commit 7d2b728

Please sign in to comment.