diff --git a/README.md b/README.md index 24046c8..22a6298 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ The plugin can be found on [npm here](https://www.npmjs.com/package/@netlify/plu - [Using Netlify Identity](#using-netlify-identity) - [Caveats](#caveats) - [Fallbacks for Pages with `getStaticPaths`](#fallbacks-for-pages-with-getstaticpaths) - - [next/image](#next/image) + - [next/image](#nextimage) - [Credits](#credits) - [Showcase](#showcase) diff --git a/lib/helpers/handleFileTracking.js b/lib/helpers/handleFileTracking.js index 8cc1465..5f19283 100644 --- a/lib/helpers/handleFileTracking.js +++ b/lib/helpers/handleFileTracking.js @@ -3,8 +3,9 @@ const { existsSync, readdirSync, readFileSync, - writeFileSync, + rmdirSync, removeSync, + writeFileSync, } = require("fs-extra"); const findCacheDir = require("find-cache-dir"); const { NETLIFY_PUBLISH_PATH, NETLIFY_FUNCTIONS_PATH } = require("../config"); @@ -18,6 +19,7 @@ const handleFileTracking = ({ functionsPath, publishPath }) => { const isConfiguredPublishDir = publishPath !== NETLIFY_PUBLISH_PATH; const cacheDir = findCacheDir({ name: "next-on-netlify", create: true }); + if (!cacheDir) return () => {}; const trackingFilePath = join(cacheDir, ".nonfiletracking"); if (existsSync(trackingFilePath)) { @@ -25,11 +27,13 @@ const handleFileTracking = ({ functionsPath, publishPath }) => { const [trackedFunctions, trackedPublish] = trackingFile.split( TRACKING_FILE_SEPARATOR ); - const cleanConfiguredFiles = (trackedFiles, dirPath) => { trackedFiles.forEach((file) => { - const filePath = join(dirPath, file); - if (file !== "" && existsSync(filePath)) { + const filePath = join(dirPath, file.trim("\r")); + if (file !== "") { + if (process.platform === "win32") { + rmdirSync(filePath, { recursive: true }); + } removeSync(filePath); } }); diff --git a/tests/fixtures/.nonfiletracking b/tests/fixtures/.nonfiletracking index 7613bf6..3381d44 100644 --- a/tests/fixtures/.nonfiletracking +++ b/tests/fixtures/.nonfiletracking @@ -1,2 +1,3 @@ next_shows_id +next_image.js --- diff --git a/tests/fixtures/my-functions/next_image.js b/tests/fixtures/my-functions/next_image.js new file mode 100644 index 0000000..e69de29