Skip to content

Commit a316e25

Browse files
committed
chore: pr feedback
1 parent 0f41c72 commit a316e25

File tree

5 files changed

+243
-230
lines changed

5 files changed

+243
-230
lines changed

src/helpers/skipPlugin.js renamed to src/helpers/shouldSkipPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { redBright, yellowBright } = require('chalk')
44
const isStaticExportProject = require('./isStaticExportProject')
55
const usesBuildCommand = require('./usesBuildCommand')
66

7-
const skipPlugin = ({ netlifyConfig, packageJson, failBuild }) => {
7+
const shouldSkipPlugin = ({ netlifyConfig, packageJson, failBuild }) => {
88
const hasNoPackageJson = Object.keys(packageJson).length === 0
99
if (hasNoPackageJson) {
1010
return failBuild('Could not find a package.json for this project')
@@ -50,4 +50,4 @@ const skipPlugin = ({ netlifyConfig, packageJson, failBuild }) => {
5050
return isStaticExportProject({ build, scripts })
5151
}
5252

53-
module.exports = skipPlugin
53+
module.exports = shouldSkipPlugin

src/index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const generateFunctions = require('./helpers/generateFunctions')
88
const getNextConfig = require('./helpers/getNextConfig')
99
const getNextRoot = require('./helpers/getNextRoot')
1010
const setIncludedFiles = require('./helpers/setIncludedFiles')
11-
const skipPlugin = require('./helpers/skipPlugin')
11+
const shouldSkipPlugin = require('./helpers/shouldSkipPlugin')
1212
const verifyBuildTarget = require('./helpers/verifyBuildTarget')
1313
const verifyNetlifyBuildVersion = require('./helpers/verifyNetlifyBuildVersion')
1414
const verifyPublishDir = require('./helpers/verifyPublishDir')
@@ -23,7 +23,7 @@ module.exports = {
2323
build: { failBuild },
2424
},
2525
}) {
26-
if (skipPlugin({ netlifyConfig, packageJson, failBuild })) {
26+
if (shouldSkipPlugin({ netlifyConfig, packageJson, failBuild })) {
2727
return
2828
}
2929

@@ -39,7 +39,18 @@ module.exports = {
3939
setIncludedFiles({ netlifyConfig, distDir })
4040
},
4141

42-
async onBuild({ netlifyConfig, constants }) {
42+
async onBuild({
43+
constants,
44+
netlifyConfig,
45+
packageJson,
46+
utils: {
47+
build: { failBuild },
48+
},
49+
}) {
50+
if (shouldSkipPlugin({ netlifyConfig, packageJson, failBuild })) {
51+
return
52+
}
53+
4354
await generateFunctions(constants)
4455

4556
const siteRoot = getNextRoot({ netlifyConfig })

test/fixtures/not-static.json

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,86 @@
11
[
2-
{
3-
"command": "npm run build",
4-
"scripts": {
5-
"build": "export"
6-
}
7-
},
8-
{
9-
"command": "npm run build",
10-
"scripts": {
11-
"build:export": "next export",
12-
"build:types": "tsc",
13-
"build": "npm run build:types"
14-
}
15-
},
16-
{
17-
"command": "npm run build",
18-
"scripts": {
19-
"export": "next export",
20-
"build:types": "tsc",
21-
"build:stuff": "tsc",
22-
"build": "run-s build:*"
23-
}
24-
},
25-
{
26-
"command": "npm run build",
27-
"scripts": {
28-
"export": "next export",
29-
"build:stuff": "tsc",
30-
"build": "run-p build:*"
31-
}
32-
},
33-
{
34-
"command": "npm run build",
35-
"scripts": {
36-
"export": "next export",
37-
"build:stuff": "tsc",
38-
"build": "npm-run-all -s build:*"
39-
}
40-
},
41-
{
42-
"command": "npm run build",
43-
"scripts": {
44-
"build:export": "next export",
45-
"build:types": "tsc",
46-
"build": "run-s build:types"
47-
}
48-
},
49-
{
50-
"command": "npm run build",
51-
"scripts": {
52-
"build:export": "next export",
53-
"build:types": "tsc",
54-
"build": "run-p build:types"
55-
}
56-
},
57-
{
58-
"command": "npm run build && npm run export",
59-
"scripts": {
60-
"export": "echo export",
61-
"build": "next build"
62-
}
63-
},
64-
{
65-
"command": "npm run build:ci:frontend",
66-
"scripts": {
67-
"build": "tsc --build",
68-
"build:ci:frontend": "npm ci && npm run build && npm run -w frontend build"
69-
}
70-
},
71-
{
72-
"command": "npm run build:ci:frontend",
73-
"scripts": {
74-
"build": "tsc --build",
75-
"build:ci:frontend": "npm ci && npm run build && npm run build:local -w frontend"
76-
}
77-
},
78-
{
79-
"command": "yarn build:ci:frontend",
80-
"scripts": {
81-
"build": "tsc --build",
82-
"build:ci:frontend": "npm ci && npm run build && yarn workspace frontend build"
83-
}
2+
{
3+
"command": "npm run build",
4+
"scripts": {
5+
"build": "export"
846
}
7+
},
8+
{
9+
"command": "npm run build",
10+
"scripts": {
11+
"build:export": "next export",
12+
"build:types": "tsc",
13+
"build": "npm run build:types"
14+
}
15+
},
16+
{
17+
"command": "npm run build",
18+
"scripts": {
19+
"export": "next export",
20+
"build:types": "tsc",
21+
"build:stuff": "tsc",
22+
"build": "run-s build:*"
23+
}
24+
},
25+
{
26+
"command": "npm run build",
27+
"scripts": {
28+
"export": "next export",
29+
"build:stuff": "tsc",
30+
"build": "run-p build:*"
31+
}
32+
},
33+
{
34+
"command": "npm run build",
35+
"scripts": {
36+
"export": "next export",
37+
"build:stuff": "tsc",
38+
"build": "npm-run-all -s build:*"
39+
}
40+
},
41+
{
42+
"command": "npm run build",
43+
"scripts": {
44+
"build:export": "next export",
45+
"build:types": "tsc",
46+
"build": "run-s build:types"
47+
}
48+
},
49+
{
50+
"command": "npm run build",
51+
"scripts": {
52+
"build:export": "next export",
53+
"build:types": "tsc",
54+
"build": "run-p build:types"
55+
}
56+
},
57+
{
58+
"command": "npm run build && npm run export",
59+
"scripts": {
60+
"export": "echo export",
61+
"build": "next build"
62+
}
63+
},
64+
{
65+
"command": "npm run build:ci:frontend",
66+
"scripts": {
67+
"build": "tsc --build",
68+
"build:ci:frontend": "npm ci && npm run build && npm run -w frontend build"
69+
}
70+
},
71+
{
72+
"command": "npm run build:ci:frontend",
73+
"scripts": {
74+
"build": "tsc --build",
75+
"build:ci:frontend": "npm ci && npm run build && npm run build:local -w frontend"
76+
}
77+
},
78+
{
79+
"command": "yarn build:ci:frontend",
80+
"scripts": {
81+
"build": "tsc --build",
82+
"build:ci:frontend": "npm ci && npm run build && yarn workspace frontend build"
83+
}
84+
}
8585

86-
]
86+
]

0 commit comments

Comments
 (0)