👽️ Use rm instead of rmdir

This commit is contained in:
trickypr 2022-07-12 15:55:25 +10:00
parent 722fcb83eb
commit d848fd1848
4 changed files with 9 additions and 22 deletions

View file

@ -1,11 +1,4 @@
import {
existsSync,
mkdirSync,
readFileSync,
rmdirSync,
unlinkSync,
writeFileSync,
} from 'fs'
import { existsSync, readFileSync, unlinkSync, writeFileSync } from 'fs'
import { join } from 'path'
import { isMatch } from 'picomatch'
import { ENGINE_DIR, MELON_TMP_DIR } from '../../constants'
@ -15,6 +8,7 @@ import {
AddonInfo,
configDispatch,
delay,
ensureDir,
walkDirectoryTree,
windowsPathToUnix,
} from '../../utils'
@ -109,13 +103,7 @@ export async function unpackAddon(
// I do not know why, but this delay causes unzip to work reliably
await delay(200)
if (existsSync(outPath)) {
rmdirSync(outPath, { recursive: true })
}
mkdirSync(outPath, {
recursive: true,
})
ensureDir(outPath)
await configDispatch('unzip', {
args: [windowsPathToUnix(path), '-d', windowsPathToUnix(outPath)],

View file

@ -1,5 +1,5 @@
import execa from 'execa'
import { existsSync, mkdirSync, rmdirSync } from 'fs'
import { existsSync } from 'fs'
import { resolve } from 'path'
import { bin_name } from '../..'
import { BASH_PATH, ENGINE_DIR, MELON_TMP_DIR } from '../../constants'
@ -30,8 +30,7 @@ export async function setupFirefoxSource(version: string) {
async function unpackFirefoxSource(name: string): Promise<void> {
log.info(`Unpacking Firefox...`)
if (existsSync(ENGINE_DIR)) rmdirSync(ENGINE_DIR)
mkdirSync(ENGINE_DIR)
ensureDir(ENGINE_DIR)
let tarExec = 'tar'

View file

@ -11,7 +11,7 @@ import {
writeFileSync,
copyFileSync,
} from 'fs'
import { copyFile, readFile, rmdir, writeFile } from 'fs/promises'
import { copyFile, readFile, rm, writeFile } from 'fs/promises'
import { every } from 'modern-async'
import { dirname, extname, join } from 'path'
import sharp from 'sharp'
@ -113,7 +113,7 @@ async function setupImages(configPath: string, outputPath: string) {
log.debug('Generating Mac Icons')
const tmp = join(MELON_TMP_DIR, 'macos_icon_info.iconset')
if (existsSync(tmp)) await rmdir(tmp, { recursive: true })
if (existsSync(tmp)) await rm(tmp, { recursive: true })
asyncIcns.convert({
input: join(configPath, 'logo.png'),

View file

@ -6,7 +6,7 @@ import {
existsSync,
mkdirSync,
openSync,
rmdirSync,
rmSync,
writeSync,
} from 'fs'
import { mkdir, readdir, stat, symlink } from 'fs/promises'
@ -168,7 +168,7 @@ export function filesExist(files: string[]): boolean {
export function ensureEmpty(path: string) {
if (existsSync(path)) {
rmdirSync(path, { recursive: true })
rmSync(path, { recursive: true })
}
mkdirSync(path, { recursive: true })