Skip to content

Commit cb29ba6

Browse files
committed
Fix sample directory and delete files
1 parent 7aa933c commit cb29ba6

File tree

10 files changed

+9
-7458
lines changed

10 files changed

+9
-7458
lines changed

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.`,

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "index.js",
66
"scripts": {
77
"format": "prettier --write .",
8-
"test": "jest"
8+
"build": "next build test/sample",
9+
"test": "npm run build && jest"
910
},
1011
"repository": {
1112
"type": "git",

test/index.js

-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const process = require('process')
33
const nextOnNetlify = require('next-on-netlify')
44
const pathExists = require('path-exists')
55
const { dir: getTmpDir } = require('tmp-promise')
6-
const execa = require('execa')
76
const cpy = require('cpy')
87

98
const plugin = require('..')
@@ -40,14 +39,6 @@ const useFixture = async function (fixtureName) {
4039
await cpy('**', process.cwd(), { cwd: fixtureDir, parents: true, overwrite: false, dot: true })
4140
}
4241

43-
// Build the sample project before running the tests
44-
beforeAll(async () => {
45-
await execa('next', ['build'], {
46-
cwd: SAMPLE_PROJECT_DIR,
47-
preferLocal: true,
48-
})
49-
}, 180 * 1000) // timeout after 180 seconds
50-
5142
// In each test, we change cwd to a temporary directory.
5243
// This allows us not to have to mock filesystem operations.
5344
beforeEach(async () => {

test/sample/netlify.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build]
2-
command = "npm run build"
2+
command = "npx next build"
33
publish = "my-publish-dir"
44

55
[[plugins]]
6-
package = "/plugins/netlify-plugin-nextjs"
6+
package = "../../"

0 commit comments

Comments
 (0)