2 Commits

Author SHA1 Message Date
fccview
968fbae13c remove bugfix from runs 2025-09-20 21:06:00 +01:00
fccview
c739d29141 quick fix for script extra character and delete issues 2025-09-20 21:05:10 +01:00
4 changed files with 16 additions and 7 deletions

View File

@@ -2,7 +2,7 @@ name: Docker
on: on:
push: push:
branches: ["main", "legacy", "feature/*", "bugfix/*"] branches: ["main", "legacy", "feature/*"]
tags: ["*"] tags: ["*"]
pull_request: pull_request:
branches: ["main"] branches: ["main"]

View File

@@ -6,7 +6,7 @@ import { join } from "path";
import { existsSync } from "fs"; import { existsSync } from "fs";
import { exec } from "child_process"; import { exec } from "child_process";
import { promisify } from "util"; import { promisify } from "util";
import { SCRIPTS_DIR } from "@/app/_utils/scripts"; import { SCRIPTS_DIR, normalizeLineEndings } from "@/app/_utils/scripts";
import { loadAllScripts, type Script } from "@/app/_utils/scriptScanner"; import { loadAllScripts, type Script } from "@/app/_utils/scriptScanner";
const execAsync = promisify(exec); const execAsync = promisify(exec);
@@ -62,7 +62,9 @@ const saveScriptFile = async (filename: string, content: string) => {
} }
const deleteScriptFile = async (filename: string) => { const deleteScriptFile = async (filename: string) => {
const scriptPath = join(await SCRIPTS_DIR(), filename); const isDocker = process.env.DOCKER === "true";
const scriptsDir = isDocker ? "/app/scripts" : await SCRIPTS_DIR();
const scriptPath = join(scriptsDir, filename);
if (existsSync(scriptPath)) { if (existsSync(scriptPath)) {
await unlink(scriptPath); await unlink(scriptPath);
} }
@@ -95,7 +97,8 @@ export const createScript = async (
`; `;
const fullContent = metadataHeader + content; const normalizedContent = normalizeLineEndings(content);
const fullContent = metadataHeader + normalizedContent;
await saveScriptFile(filename, fullContent); await saveScriptFile(filename, fullContent);
revalidatePath("/"); revalidatePath("/");
@@ -145,7 +148,8 @@ export const updateScript = async (
`; `;
const fullContent = metadataHeader + content; const normalizedContent = normalizeLineEndings(content);
const fullContent = metadataHeader + normalizedContent;
await saveScriptFile(existingScript.filename, fullContent); await saveScriptFile(existingScript.filename, fullContent);
revalidatePath("/"); revalidatePath("/");
@@ -203,7 +207,8 @@ export const cloneScript = async (
`; `;
const fullContent = metadataHeader + originalContent; const normalizedContent = normalizeLineEndings(originalContent);
const fullContent = metadataHeader + normalizedContent;
await saveScriptFile(filename, fullContent); await saveScriptFile(filename, fullContent);
revalidatePath("/"); revalidatePath("/");

View File

@@ -21,4 +21,8 @@ export const getHostScriptPath = async (filename: string): Promise<string> => {
return `bash ${join(hostScriptsDir, filename)}`; return `bash ${join(hostScriptsDir, filename)}`;
} }
export const normalizeLineEndings = (content: string): string => {
return content.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
};
export { SCRIPTS_DIR }; export { SCRIPTS_DIR };

View File

@@ -2,5 +2,5 @@
# @title: Hi, this is a demo script # @title: Hi, this is a demo script
# @description: This script logs a "hello world" to teach you how scripts work. # @description: This script logs a "hello world" to teach you how scripts work.
#!/bin/bash #!/bin/bash
echo 'Hello World' > hello.txt echo 'Hello World' > hello.txt