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

Commit ba4f141

Browse files
committed
fix file tracking bug and add more rigid testing
1 parent ba22d52 commit ba4f141

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

lib/helpers/handleFileTracking.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ const handleFileTracking = ({ functionsPath, publishPath }) => {
2626
TRACKING_FILE_SEPARATOR
2727
);
2828

29-
const cleanConfiguredFiles = (trackedFiles) => {
29+
const cleanConfiguredFiles = (trackedFiles, dirPath) => {
3030
trackedFiles.forEach((file) => {
31-
const filePath = join(publishPath, file);
31+
const filePath = join(dirPath, file);
3232
if (file !== "" && existsSync(filePath)) {
3333
removeSync(filePath);
3434
}
3535
});
3636
};
3737

3838
if (isConfiguredPublishDir) {
39-
cleanConfiguredFiles(trackedPublish.split("\n"));
39+
cleanConfiguredFiles(trackedPublish.split("\n"), publishPath);
4040
}
4141
if (isConfiguredFunctionsDir) {
42-
cleanConfiguredFiles(trackedFunctions.split("\n"));
42+
cleanConfiguredFiles(trackedFunctions.split("\n"), functionsPath);
4343
}
4444
}
4545

tests/configurableDirs.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ beforeAll(
2626
.withNextConfig("next.config.js")
2727
.withPackageJson("package.json")
2828
.withCustomFunctions("my-functions")
29+
.withFileTracking()
2930
.runWithRequire({ functionsDir: FUNCTIONS_DIR, publishDir: PUBLISH_DIR });
3031
},
3132
// time out after 180 seconds

tests/fixtures/.nonfiletracking

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
next_shows_id
2+
---

tests/fixtures/my-functions/next_shows_id/next_shows_id.js

Whitespace-only changes.

tests/helpers/buildNextApp.js

+7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ class NextAppBuilder {
5050
return this.withFile(functionsDir);
5151
}
5252

53+
withFileTracking() {
54+
return this.withFile(
55+
".nonfiletracking",
56+
join("node_modules", ".cache", "next-on-netlify", ".nonfiletracking")
57+
);
58+
}
59+
5360
// Copy a file from the fixtures folder to the app's staging folder
5461
withFile(fixture, target = null) {
5562
// If no target file name is given, use the same name as the fixture

0 commit comments

Comments
 (0)