Skip to content

Commit

Permalink
chore: nudge to install the @netlify/functions package
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasholzer committed Oct 5, 2023
1 parent a2d5436 commit 6355b77
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/lib/functions/check-tsconfig-for-v2-api.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// @ts-check
import { existsSync } from 'fs'
import { writeFile } from 'fs/promises'
import { createRequire } from 'module'
import { join } from 'path'

import { parseTsconfig } from 'get-tsconfig'
import terminalLink from 'terminal-link'

import { NETLIFYDEVLOG, chalk, log } from '../../utils/command-helpers.mjs'
import { NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, log } from '../../utils/command-helpers.mjs'

/**
* The `tsconfig.json` we are going to write to the functions directory.
Expand Down Expand Up @@ -44,6 +45,16 @@ export async function checkTsconfigForV2Api(config) {
return
}

try {
const require = createRequire(config.functionsDir)
require.resolve('@netlify/functions')
} catch {
log(
`${NETLIFYDEVWARN} Please install the ${chalk.dim(
'@netlify/functions',
)} package to get a better typed experience!`,
)
}
const tsconfig = join(config.functionsDir, 'tsconfig.json')

if (existsSync(tsconfig)) {
Expand Down

0 comments on commit 6355b77

Please sign in to comment.