mirror of
https://github.com/zen-browser/surfer.git
synced 2025-07-07 17:05:33 +02:00
✨ Add force option to download command
This commit is contained in:
parent
e79d4b099c
commit
77a63264b7
4 changed files with 24 additions and 12 deletions
|
@ -1,6 +1,8 @@
|
|||
import execa from 'execa'
|
||||
import { existsSync, rmSync, writeFileSync } from 'node:fs'
|
||||
import { readdir } from 'node:fs/promises'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
|
||||
import { bin_name } from '../..'
|
||||
import { BASH_PATH, ENGINE_DIR, MELON_TMP_DIR } from '../../constants'
|
||||
import { log } from '../../log'
|
||||
|
@ -19,7 +21,6 @@ import {
|
|||
unpackAddon,
|
||||
} from './addon'
|
||||
import { configPath } from '../../utils'
|
||||
import { readdir } from 'node:fs/promises'
|
||||
|
||||
export function shouldSetupFirefoxSource() {
|
||||
return !(
|
||||
|
@ -111,7 +112,7 @@ async function downloadFirefoxSource(version: string) {
|
|||
return filename
|
||||
}
|
||||
|
||||
export async function downloadInternals(version: string) {
|
||||
export async function downloadInternals({ version, force }: { version: string, force?: boolean }) {
|
||||
// Provide a legible error if there is no version specified
|
||||
if (!version) {
|
||||
log.error(
|
||||
|
@ -120,6 +121,11 @@ export async function downloadInternals(version: string) {
|
|||
process.exit(1)
|
||||
}
|
||||
|
||||
if (force && existsSync(ENGINE_DIR)) {
|
||||
log.info('Removing existing workspace')
|
||||
rmSync(ENGINE_DIR, { recursive: true })
|
||||
}
|
||||
|
||||
// If the engine directory is empty, we should delete it.
|
||||
const engineIsEmpty = await readdir(ENGINE_DIR).then((files) => files.length === 0)
|
||||
if (existsSync(ENGINE_DIR) && engineIsEmpty) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue