Skip to content

Commit

Permalink
chore: update checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic committed Aug 18, 2022
1 parent 68710db commit 398efb1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/runtime/src/helpers/dev.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { resolve } from 'path'

import { NetlifyPlugin } from '@netlify/build'
import { OnPreBuild } from '@netlify/build'
import execa from 'execa'
import { unlink, existsSync } from 'fs-extra'

import { writeDevEdgeFunction } from './edge'
import { patchNextFiles } from './files'

// The types haven't been updated yet
export const onPreDev: NetlifyPlugin['onPreBuild'] = async ({ constants, netlifyConfig }) => {
export const onPreDev: OnPreBuild = async ({ constants, netlifyConfig }) => {
// Need to patch the files, because build might not have been run
await patchNextFiles(resolve(netlifyConfig.build.publish, '..'))

Expand Down
7 changes: 5 additions & 2 deletions packages/runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
warnForRootRedirects,
} from './helpers/verification'

const plugin: NetlifyPlugin & { onPreDev?: OnPreBuild; onDev?: OnPreBuild } = {
const plugin: NetlifyPlugin = {
async onPreBuild({
constants,
netlifyConfig,
Expand Down Expand Up @@ -220,7 +220,10 @@ const plugin: NetlifyPlugin & { onPreDev?: OnPreBuild; onDev?: OnPreBuild } = {
},
}
// The types haven't been updated yet
const nextRuntime = (_inputs, meta: { events?: Set<string> } = {}): NetlifyPlugin & { onPreDev?: OnPreBuild } => {
const nextRuntime = (
_inputs,
meta: { events?: Set<string> } = {},
): NetlifyPlugin & { onPreDev?: NetlifyPlugin['onPreBuild'] } => {
if (!meta?.events?.has('onPreDev')) {
return {
...plugin,
Expand Down
8 changes: 5 additions & 3 deletions packages/runtime/src/templates/edge/next-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ const exists = async (relativePath: string) => {
}

const handler = async (req: Request, context: Context) => {
// if (!Deno.env.get('NETLIFY_DEV')) {
// return
// }
if (!Deno.env.get('NETLIFY_DEV')) {
// Only run in dev
return
}

let middleware
// Dynamic imports and FS operations aren't allowed when deployed,
// but that's fine because this is only ever used locally.
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/src/templates/edge/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ globalThis.NFRequestContextMap ||= new Map()

const handler = async (req: Request, context: Context) => {
if (Deno.env.get('NETLIFY_DEV')) {
console.log('is dev')
// Don't run in dev
return
}
const url = new URL(req.url)
Expand Down

0 comments on commit 398efb1

Please sign in to comment.