Skip to content

#53 properly test next-on-netlify in onBuild #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 2, 2020
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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
### Node ###

# Test
test/sample/node_modules
test/sample/out_functions
test/sample/netlify-automatic-functions
test/sample/my-publish-dir
test/sample/.next
test/sample/.netlify

# Logs
logs
*.log
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ node_modules

# Test
__mocks__
sample
test/fixtures
test/sample
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const util = require('util')
const findUp = require('find-up')
const makeDir = require('make-dir')

const { name: pluginName } = require('./package.json')
const isStaticExportProject = require('./helpers/isStaticExportProject')
const validateNextUsage = require('./helpers/validateNextUsage')

Expand All @@ -25,7 +26,7 @@ module.exports = {
}

const { build } = netlifyConfig
const { scripts = {}, dependencies = {} } = packageJson
const { name, scripts = {}, dependencies = {} } = packageJson

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