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

View file

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

View file

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

View file

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