3 Commits
1.4.0 ... 1.4.1

Author SHA1 Message Date
fccview
65ac81d97c Merge pull request #40 from fccview/bugfix/fix-scripts-issues
Bugfix/fix scripts issues
2025-09-20 21:14:07 +01:00
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:
push:
branches: ["main", "legacy", "feature/*", "bugfix/*"]
branches: ["main", "legacy", "feature/*"]
tags: ["*"]
pull_request:
branches: ["main"]

View File

@@ -6,7 +6,7 @@ import { join } from "path";
import { existsSync } from "fs";
import { exec } from "child_process";
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";
const execAsync = promisify(exec);
@@ -62,7 +62,9 @@ const saveScriptFile = async (filename: string, content: 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)) {
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);
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);
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);
revalidatePath("/");

View File

@@ -21,4 +21,8 @@ export const getHostScriptPath = async (filename: string): Promise<string> => {
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 };

View File

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