Skip to content

Commit 9da8be5

Browse files
#53 properly test next-on-netlify in onBuild (#65)
* use .next dist to properly test next-on-netlify * update next-on-netlify testing to use sample/.next dist * move /test/fixtures/sample to /test/sample * Fix files copy * Fix sample directory and delete files * remove unnecessary items * remove plugins dir in test/sample Co-authored-by: ehmicky <[email protected]>
1 parent 157619c commit 9da8be5

23 files changed

+652
-7989
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
### Node ###
2+
3+
# Test
4+
test/sample/node_modules
5+
test/sample/out_functions
6+
test/sample/netlify-automatic-functions
7+
test/sample/my-publish-dir
8+
test/sample/.next
9+
test/sample/.netlify
10+
211
# Logs
312
logs
413
*.log

.prettierignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ node_modules
1818

1919
# Test
2020
__mocks__
21-
sample
21+
test/fixtures
22+
test/sample

index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const util = require('util')
55
const findUp = require('find-up')
66
const makeDir = require('make-dir')
77

8+
const { name: pluginName } = require('./package.json')
89
const isStaticExportProject = require('./helpers/isStaticExportProject')
910
const validateNextUsage = require('./helpers/validateNextUsage')
1011

@@ -25,7 +26,7 @@ module.exports = {
2526
}
2627

2728
const { build } = netlifyConfig
28-
const { scripts = {}, dependencies = {} } = packageJson
29+
const { name, scripts = {}, dependencies = {} } = packageJson
2930

3031
if (isStaticExportProject({ build, scripts })) {
3132
return failBuild(`** Static HTML export next.js projects do not require this plugin **`)
@@ -34,7 +35,8 @@ module.exports = {
3435
const hasNextOnNetlifyInstalled = dependencies['next-on-netlify'] !== undefined
3536
const hasNextOnNetlifyPostbuildScript =
3637
typeof scripts.postbuild === 'string' && scripts.postbuild.includes('next-on-netlify')
37-
const isAlreadyUsingNextOnNetlify = hasNextOnNetlifyInstalled || hasNextOnNetlifyPostbuildScript
38+
const isAlreadyUsingNextOnNetlify =
39+
(hasNextOnNetlifyInstalled || hasNextOnNetlifyPostbuildScript) && pluginName !== name
3840
if (isAlreadyUsingNextOnNetlify) {
3941
return failBuild(
4042
`This plugin does not support sites that manually use next-on-netlify. Uninstall next-on-netlify as a dependency to resolve.`,

0 commit comments

Comments
 (0)