From 6df9c7a20abd14641309490292c058b123e2dd88 Mon Sep 17 00:00:00 2001 From: JrMasterModelBuilder Date: Fri, 20 Oct 2023 23:46:45 -0400 Subject: [PATCH] Preserve mode --- src/projector/otto/mac.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/projector/otto/mac.ts b/src/projector/otto/mac.ts index 2a59421..888a658 100644 --- a/src/projector/otto/mac.ts +++ b/src/projector/otto/mac.ts @@ -1,10 +1,12 @@ -import {readFile, mkdir, writeFile} from 'node:fs/promises'; +import {readFile, mkdir, writeFile, chmod} from 'node:fs/promises'; import {join as pathJoin, basename, dirname} from 'node:path'; import { PathType, Entry, - createArchiveByFileStatOrThrow + createArchiveByFileStatOrThrow, + fsLchmodSupported, + fsLchmod } from '@shockpkg/archive-files'; import {Plist, ValueDict, ValueString} from '@shockpkg/plist-dom'; @@ -557,6 +559,14 @@ export class ProjectorOttoMac extends ProjectorOtto { if (data) { await mkdir(dirname(dest), {recursive: true}); await writeFile(dest, data); + const {mode} = entry; + if (mode) { + if (fsLchmodSupported) { + await fsLchmod(dest, mode); + } else { + await chmod(dest, mode); + } + } return; }