1
1
mirror of https://github.com/neosubhamoy/neodlp.git synced 2026-03-22 08:05:48 +05:30

refactor: use sh and printf to write

This commit is contained in:
2026-02-26 20:20:57 +05:30
Verified
parent f0e31cd15e
commit 3b234c766e
2 changed files with 6 additions and 10 deletions

View File

@@ -66,13 +66,8 @@
"args": true "args": true
}, },
{ {
"name": "cp", "name": "sh",
"cmd": "cp", "cmd": "sh",
"args": true
},
{
"name": "echo",
"cmd": "echo",
"args": true "args": true
} }
] ]

View File

@@ -35,7 +35,7 @@ export function useLinuxRegisterer() {
description: "NeoDLP MsgHost", description: "NeoDLP MsgHost",
path: `${homeDirPath}/.local/bin/neodlp-msghost`, path: `${homeDirPath}/.local/bin/neodlp-msghost`,
type: "stdio", type: "stdio",
allowed_extension: ["neodlp@neosubhamoy.com"] allowed_extensions: ["neodlp@neosubhamoy.com"]
}; };
const filesToCopy: FileMap[] = [ const filesToCopy: FileMap[] = [
@@ -56,8 +56,9 @@ export function useLinuxRegisterer() {
for (const file of filesToCopyFlatpak) { for (const file of filesToCopyFlatpak) {
const sourcePath = await join(resourceDirPath, file.source); const sourcePath = await join(resourceDirPath, file.source);
const destinationPath = await join(homeDirPath, file.destination); const destinationPath = await join(homeDirPath, file.destination);
const copyCommand = Command.create('cp', [sourcePath, destinationPath]); const escapedContent = file.content?.replace(/'/g, `'\\''`) || '';
const writeCommand = Command.create('echo', [file.content || '', '>', destinationPath]); const copyCommand = Command.create('sh', ['-c', 'cp', sourcePath, destinationPath]);
const writeCommand = Command.create('sh', ['-c', `printf '%s' '${escapedContent}' > "${destinationPath}"`]);
if (file.content) { if (file.content) {
const writeOutput = await writeCommand.execute(); const writeOutput = await writeCommand.execute();