mirror of
https://github.com/fccview/cronmaster.git
synced 2025-12-24 06:28:26 -05:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65ac81d97c | ||
|
|
968fbae13c | ||
|
|
c739d29141 |
2
.github/workflows/docker-publish.yml
vendored
2
.github/workflows/docker-publish.yml
vendored
@@ -2,7 +2,7 @@ name: Docker
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main", "legacy", "feature/*", "bugfix/*"]
|
||||
branches: ["main", "legacy", "feature/*"]
|
||||
tags: ["*"]
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
|
||||
@@ -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("/");
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user