Skip to content

Commit

Permalink
chore: add util back
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Oct 10, 2024
1 parent 1cdda62 commit ad595f8
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/zip-it-and-ship-it/tests/helpers/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { rm } from 'fs/promises'
import { mkdir, rm } from 'fs/promises'
import { dirname, resolve, join, basename, relative } from 'path'
import { env } from 'process'
import { env, platform } from 'process'
import { fileURLToPath } from 'url'

import { unzipFile } from '@netlify/testing'
import { execa } from 'execa'
import isCI from 'is-ci'
import { dir as getTmpDir } from 'tmp-promise'
import { afterAll, expect } from 'vitest'
Expand Down Expand Up @@ -138,6 +138,16 @@ export const unzipFiles = async function (files: FunctionResult[]): Promise<Test
return files as TestFunctionResult[]
}

const unzipFile = async function (path: string, dest: string): Promise<void> {
await mkdir(dest, { recursive: true })

if (platform === 'win32') {
await execa('tar', ['-xf', path, '-C', dest])
} else {
await execa('unzip', ['-o', path, '-d', dest])
}
}

const replaceUnzipPath = function ({ path }: { path: string }): string {
return join(path.replace(/.zip$/, ''), basename(path).replace(/.zip$/, '.js'))
}
Expand Down

0 comments on commit ad595f8

Please sign in to comment.