surfer/src/commands/update.ts
trickypr 97a87f5eb4 🐛 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.
2022-11-14 19:33:25 +11:00

30 lines
1 KiB
TypeScript

// 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
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
import { existsSync, rmSync } from 'node:fs'
import { bin_name, config } from '..'
import { log } from '../log'
import {
downloadInternals
} from './download/firefox'
import { getLatestFF } from '../utils'
import { ENGINE_DIR } from '../constants'
export const update = async (): Promise<void> => {
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)
log.success(
`Firefox has successfully been updated to ${version}.`,
`You should be ready to make changes to ${config.name}.`,
'',
`You should import the patches next, run |${bin_name} import|.`,
`To begin building ${config.name}, run |${bin_name} build|.`
)
console.log()
}