Skip to content

Commit

Permalink
fix: use relative path when printing out cleaned up blob paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstork committed Apr 23, 2024
1 parent 4ade4b0 commit 7129085
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
21 changes: 13 additions & 8 deletions packages/build/src/plugins_core/pre_dev_cleanup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { resolve } from 'node:path'
import { listFrameworks } from '@netlify/framework-info'

import { log } from '../../log/logger.js'
import { getBlobsDirs } from '../../utils/blobs.js'
import { DEPLOY_CONFIG_BLOBS_PATH, LEGACY_BLOBS_PATH } from '../../utils/blobs.js'
import { CoreStep, CoreStepCondition, CoreStepFunction, CoreStepFunctionArgs } from '../types.js'

const dirExists = async (path: string): Promise<boolean> => {
Expand All @@ -23,18 +23,23 @@ const getDirtyDirs = async function ({
}: CoreStepFunctionArgs): Promise<string[]> {
const directories: string[] = []

if (INTERNAL_FUNCTIONS_SRC && (await dirExists(resolve(buildDir, INTERNAL_FUNCTIONS_SRC)))) {
if (INTERNAL_FUNCTIONS_SRC && (await dirExists(resolve(buildDir, packagePath || '', INTERNAL_FUNCTIONS_SRC)))) {
directories.push(INTERNAL_FUNCTIONS_SRC)
}

if (INTERNAL_EDGE_FUNCTIONS_SRC && (await dirExists(resolve(buildDir, INTERNAL_EDGE_FUNCTIONS_SRC)))) {
if (
INTERNAL_EDGE_FUNCTIONS_SRC &&
(await dirExists(resolve(buildDir, packagePath || '', INTERNAL_EDGE_FUNCTIONS_SRC)))
) {
directories.push(INTERNAL_EDGE_FUNCTIONS_SRC)
}

for (const blobDirectory of getBlobsDirs(buildDir, packagePath)) {
if (await dirExists(blobDirectory)) {
directories.push(blobDirectory)
}
if (await dirExists(resolve(buildDir, packagePath || '', LEGACY_BLOBS_PATH))) {
directories.push(LEGACY_BLOBS_PATH)
}

if (await dirExists(resolve(buildDir, packagePath || '', DEPLOY_CONFIG_BLOBS_PATH))) {
directories.push(DEPLOY_CONFIG_BLOBS_PATH)
}

return directories
Expand All @@ -43,7 +48,7 @@ const getDirtyDirs = async function ({
const coreStep: CoreStepFunction = async (input) => {
const dirs = await getDirtyDirs(input)
for (const dir of dirs) {
await rm(resolve(input.buildDir, dir), { recursive: true, force: true })
await rm(resolve(input.buildDir, input.packagePath || '', dir), { recursive: true, force: true })
}
log(input.logs, `Cleaned up ${dirs.join(', ')}.`)
return {}
Expand Down
4 changes: 2 additions & 2 deletions packages/build/src/utils/blobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import path from 'node:path'

import { fdir } from 'fdir'

const LEGACY_BLOBS_PATH = '.netlify/blobs/deploy'
const DEPLOY_CONFIG_BLOBS_PATH = '.netlify/deploy/v1/blobs/deploy'
export const LEGACY_BLOBS_PATH = '.netlify/blobs/deploy'
export const DEPLOY_CONFIG_BLOBS_PATH = '.netlify/deploy/v1/blobs/deploy'

/** Retrieve the absolute path of the deploy scoped internal blob directories */
export const getBlobsDirs = (buildDir: string, packagePath?: string) => [
Expand Down

0 comments on commit 7129085

Please sign in to comment.