File tree 2 files changed +19
-3
lines changed
2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 4
4
5
5
const isStaticExportProject = ( { build, scripts } ) => {
6
6
const NEXT_EXPORT_COMMAND = 'next export'
7
- const isSetInNetlifyConfig = build && build . command && build . command . includes ( NEXT_EXPORT_COMMAND )
7
+
8
+ if ( ! build || ! build . command ) return
9
+
10
+ const isSetInNetlifyConfig = build . command . includes ( NEXT_EXPORT_COMMAND )
11
+
8
12
const isSetInNpmScript = Object . keys ( scripts ) . find ( ( script ) => {
9
- return scripts [ script ] . includes ( NEXT_EXPORT_COMMAND )
13
+ const scriptValue = scripts [ script ]
14
+ return build . command . includes ( script ) && scriptValue . includes ( NEXT_EXPORT_COMMAND )
10
15
} )
11
16
return isSetInNetlifyConfig || isSetInNpmScript
12
17
}
Original file line number Diff line number Diff line change @@ -63,14 +63,25 @@ describe('preBuild()', () => {
63
63
test ( 'fail build if the app has static html export in npm script' , async ( ) => {
64
64
await expect (
65
65
plugin . onPreBuild ( {
66
- netlifyConfig : { } ,
66
+ netlifyConfig : { build : { command : 'npm run build' } } ,
67
67
packageJson : { ...DUMMY_PACKAGE_JSON , scripts : { build : 'next export' } } ,
68
68
utils,
69
69
constants : { FUNCTIONS_SRC : 'out_functions' } ,
70
70
} ) ,
71
71
) . rejects . toThrow ( '** Static HTML export next.js projects do not require this plugin **' )
72
72
} )
73
73
74
+ test ( 'do not fail build if the app has next export in an unused script' , async ( ) => {
75
+ await expect (
76
+ plugin . onPreBuild ( {
77
+ netlifyConfig : { } ,
78
+ packageJson : { ...DUMMY_PACKAGE_JSON , scripts : { export : 'next export' } } ,
79
+ utils,
80
+ constants : { } ,
81
+ } ) ,
82
+ ) . resolves
83
+ } )
84
+
74
85
test ( 'fail build if the app has static html export in toml/ntl config' , async ( ) => {
75
86
await expect (
76
87
plugin . onPreBuild ( {
You can’t perform that action at this time.
0 commit comments