Skip to content

Commit

Permalink
Merge pull request #947 from OpenAF/t8
Browse files Browse the repository at this point in the history
T8
  • Loading branch information
nmaguiar authored Feb 6, 2024
2 parents 45fda96 + b3877aa commit 04a1d0f
Show file tree
Hide file tree
Showing 16 changed files with 490 additions and 262 deletions.
13 changes: 7 additions & 6 deletions js/genSB.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var tmpl = "#!/usr/bin/env {{openAFPath}}oaf-sb\n\nvar params = processExpr(\" \
var tmplJ = "#!/usr/bin/env {{openAFPath}}ojob-sb\n\n"

var isoJob = false
var isWin = String(java.lang.System.getProperty("os.name")).match(/Windows/)
if (io.fileExists(expr)) {
if (!expr.endsWith(".js")) isoJob = true
if (io.readFileString(expr).replace(/\n/g, "").trim().substring(0, 2) == "#!")
Expand All @@ -13,9 +14,9 @@ if (io.fileExists(expr)) {
io.writeFileString(expr, templify((isoJob ? tmplJ : tmpl), {
openAFPath: getOpenAFPath()
}) + io.readFileString(expr));
$sh("chmod u+x " + expr)
.prefix("chmod")
.get(0);
if (!isWin) $sh("chmod u+x " + expr)
.prefix("chmod")
.get(0)
log("Pre-appended " + (isoJob ? "oJob" : "OpenAF") + " shebang instructions to file: " + expr);
if (!isoJob) log("On OpenAF use the 'params' variable to access any parameter you pass executing the script like: " + io.fileInfo(expr).canonicalPath + " abc=123 xzy=aaa");
}
Expand All @@ -24,9 +25,9 @@ if (io.fileExists(expr)) {
io.writeFileString(expr, templify((isoJob ? tmplJ : tmpl), {
openAFPath: getOpenAFPath()
}));
$sh("chmod u+x " + expr)
.prefix("chmod")
.get(0);
if (!isWin) $sh("chmod u+x " + expr)
.prefix("chmod")
.get(0)
log("Generated " + (isoJob ? "oJob" : "OpenAF") + " shebang file: " + expr);
if (!isoJob) log("On OpenAF use the 'params' variable to access any parameter you pass executing the script like: " + io.fileInfo(expr).canonicalPath + " abc=123 xzy=aaa");
}
Loading

0 comments on commit 04a1d0f

Please sign in to comment.