Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

fix windows test in file tracking work #142

Merged
merged 1 commit into from
Jan 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 8 additions & 4 deletions lib/helpers/handleFileTracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -18,18 +19,21 @@ 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)) {
const trackingFile = readFileSync(trackingFilePath, "utf8");
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);
}
});
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/.nonfiletracking
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
next_shows_id
next_image.js
---
Empty file.