Skip to content

Commit 7b9492d

Browse files
committed
chore: fix tests
1 parent cda8036 commit 7b9492d

File tree

5 files changed

+8
-11
lines changed

5 files changed

+8
-11
lines changed

src/utils/detect-server-settings.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ const detectFrameworkSettings = async ({ projectDir }) => {
215215
}
216216
}
217217

218-
/** @deprecated remove it */
219218
const hasCommandAndTargetPort = ({ devConfig }) => devConfig.command && devConfig.targetPort
220219

221220
/**
@@ -279,11 +278,10 @@ const detectServerSettings = async (devConfig, flags, projectDir) => {
279278
} else if (devConfig.framework === '#auto') {
280279
// this is the default CLI behavior
281280

282-
// detect the framework settings
283-
const frameworkSettings = await detectFrameworkSettings({ projectDir })
281+
const runDetection = !hasCommandAndTargetPort({ devConfig })
282+
const frameworkSettings = runDetection ? await detectFrameworkSettings({ projectDir }) : undefined
284283

285-
console.log(devConfig.targetPort)
286-
if (frameworkSettings === undefined) {
284+
if (frameworkSettings === undefined && runDetection) {
287285
log(`${NETLIFYDEVWARN} No app server detected. Using simple static server`)
288286
settings = await handleStaticServer({ flags, devConfig, projectDir })
289287
} else {

src/utils/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type FrameworkNames = '#static' | '#auto' | '#custom'
1+
export type FrameworkNames = '#static' | '#auto' | '#custom' | string
22

33
export type FrameworkInfo = {
44
build: {

tests/framework-detection.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ test('should use static server when framework is set to #static', async (t) => {
6565
})
6666
})
6767

68-
test('should warn if using static server and `command` is configured', async (t) => {
68+
test('should log the command if using static server and `command` is configured', async (t) => {
6969
await withSiteBuilder('site-with-index-file', async (builder) => {
7070
await builder
7171
.withContentFile({

tests/snapshots/framework-detection.test.js.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,12 @@ Generated by [AVA](https://avajs.dev).
6464
6565
`
6666

67-
## should warn if using static server and `command` is configured
67+
## should log the command if using static server and `command` is configured
6868

6969
> Snapshot 1
7070
7171
`◈ Netlify Dev ◈␊
7272
◈ Using simple static server because '--dir' flag was specified␊
73-
◈ Ignoring command setting since using a simple static server. Configure 'command' and 'targetPort' for a custom setup␊
7473
◈ Running static server from "site-with-index-file/public"␊
7574
7675
◈ Static server listening to 88888␊
@@ -118,7 +117,7 @@ Generated by [AVA](https://avajs.dev).
118117
119118
`◈ Netlify Dev ◈␊
120119
◈ Starting Netlify Dev with Create React App␊
121-
◈ Failed launching framework server. Please verify 'react-scripts' exists`
120+
◈ Failed running command: react-scripts start. Please verify 'react-scripts' exists`
122121

123122
## should throw when forcing a non supported framework
124123

@@ -171,7 +170,7 @@ Generated by [AVA](https://avajs.dev).
171170
◈ Setup a netlify.toml file with a [dev] section to specify your dev server settings.␊
172171
◈ See docs at: https://cli.netlify.com/netlify-dev#project-detection␊
173172
◈ Starting Netlify Dev with #custom␊
174-
◈ Failed launching framework server. Please verify 'oops-i-did-it-again' exists`
173+
◈ Failed running command: oops-i-did-it-again forgot-to-use-a-valid-command. Please verify 'oops-i-did-it-again' exists`
175174

176175
## should prompt when multiple frameworks are detected
177176

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)