mirror of
https://github.com/zen-browser/surfer.git
synced 2025-07-08 01:10:03 +02:00
🐛 Don't delete the engine directory every download
The primary justification for this is adding/updating extensions. Ideally, you should just be able to run `download` again to get the new extensions, which the current implementation does not allow for.
This commit is contained in:
parent
c5db3d7b6a
commit
97a87f5eb4
3 changed files with 18 additions and 6 deletions
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Improved error handling and logging for the download command
|
- Improved error handling and logging for the download command
|
||||||
|
- `download`: The `engine/` directory will only be deleted if it is empty. Otherwise it will skip. Justification can be found in [#27](https://github.com/pulse-browser/gluon/issues/27)
|
||||||
|
|
||||||
## [1.0.0-rc.2]
|
## [1.0.0-rc.2]
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {
|
||||||
unpackAddon,
|
unpackAddon,
|
||||||
} from './addon'
|
} from './addon'
|
||||||
import { configPath } from '../../utils'
|
import { configPath } from '../../utils'
|
||||||
|
import { readdir } from 'node:fs/promises'
|
||||||
|
|
||||||
export function shouldSetupFirefoxSource() {
|
export function shouldSetupFirefoxSource() {
|
||||||
return !(
|
return !(
|
||||||
|
@ -111,7 +112,7 @@ async function downloadFirefoxSource(version: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function downloadInternals(version: string) {
|
export async function downloadInternals(version: string) {
|
||||||
// If gFFVersion isn't specified, provide legible error
|
// Provide a legible error if there is no version specified
|
||||||
if (!version) {
|
if (!version) {
|
||||||
log.error(
|
log.error(
|
||||||
'You have not specified a version of firefox in your config file. This is required to build a firefox fork.'
|
'You have not specified a version of firefox in your config file. This is required to build a firefox fork.'
|
||||||
|
@ -119,9 +120,15 @@ export async function downloadInternals(version: string) {
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existsSync(ENGINE_DIR)) {
|
// If the engine directory is empty, we should delete its contents
|
||||||
log.info("Deleting engine/")
|
const engineIsEmpty = await readdir(ENGINE_DIR).then((files) => files.length === 0)
|
||||||
rmSync(ENGINE_DIR)
|
if (existsSync(ENGINE_DIR) && engineIsEmpty) {
|
||||||
|
log.info("'engine/' is empty, deleting contents...")
|
||||||
|
rmSync(ENGINE_DIR, { recursive: true })
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!existsSync(ENGINE_DIR)) {
|
||||||
await setupFirefoxSource(version)
|
await setupFirefoxSource(version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,26 @@
|
||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
import { existsSync, rmSync } from 'node:fs'
|
||||||
|
|
||||||
import { bin_name, config } from '..'
|
import { bin_name, config } from '..'
|
||||||
import { log } from '../log'
|
import { log } from '../log'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
downloadInternals
|
downloadInternals
|
||||||
} from './download/firefox'
|
} from './download/firefox'
|
||||||
import { getLatestFF } from '../utils'
|
import { getLatestFF } from '../utils'
|
||||||
|
import { ENGINE_DIR } from '../constants'
|
||||||
|
|
||||||
export const update = async (): Promise<void> => {
|
export const update = async (): Promise<void> => {
|
||||||
const version = await getLatestFF(config.version.product)
|
const version = await getLatestFF(config.version.product)
|
||||||
|
|
||||||
|
// Delete the existing engine directory to download the new version
|
||||||
|
if (existsSync(ENGINE_DIR)) rmSync(ENGINE_DIR, { recursive: true })
|
||||||
|
|
||||||
await downloadInternals(version)
|
await downloadInternals(version)
|
||||||
|
|
||||||
log.success(
|
log.success(
|
||||||
`Firefox has sucessfully been updated to ${version}.`,
|
`Firefox has successfully been updated to ${version}.`,
|
||||||
`You should be ready to make changes to ${config.name}.`,
|
`You should be ready to make changes to ${config.name}.`,
|
||||||
'',
|
'',
|
||||||
`You should import the patches next, run |${bin_name} import|.`,
|
`You should import the patches next, run |${bin_name} import|.`,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue