From b76fad10bb8f416d908b80f5cde1270ca4e1343e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6n=20G=20Limell?= Date: Sun, 2 Jan 2022 13:48:11 +0100 Subject: [PATCH 1/2] Check if directory exists, before compressing --- packages/adapter-node/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/adapter-node/index.js b/packages/adapter-node/index.js index 863fdba5072f..9d7f400090b3 100644 --- a/packages/adapter-node/index.js +++ b/packages/adapter-node/index.js @@ -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'; @@ -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, From 39f1fc803e3ad2dd179bc7d47a5c0f44c8e2f651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6n=20G=20Limell?= Date: Sun, 2 Jan 2022 13:49:37 +0100 Subject: [PATCH 2/2] Added changeset --- .changeset/tiny-horses-rush.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tiny-horses-rush.md diff --git a/.changeset/tiny-horses-rush.md b/.changeset/tiny-horses-rush.md new file mode 100644 index 000000000000..4d8ae2ded4c1 --- /dev/null +++ b/.changeset/tiny-horses-rush.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-node': patch +--- + +Check if directory exists, before compressing