Skip to content

Commit 0c6affc

Browse files
authored
Merge pull request #1078 from OpenAF/t8
T8
2 parents 4494639 + 77c4c55 commit 0c6affc

File tree

5 files changed

+83
-34
lines changed

5 files changed

+83
-34
lines changed

js/genSB.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,30 @@
33

44
var tmpl = "#!/usr/bin/env {{openAFPath}}oaf-sb\n\nvar params = processExpr(\" \");\n// sprint(params)\n\n";
55
var tmplJ = "#!/usr/bin/env {{openAFPath}}ojob-sb\n\n"
6+
var tmplP = "#!/usr/bin/env {{openAFPath}}oafp-sb\n"
67

7-
var isoJob = false
8+
var isoJob = false, isoafp = false
89
var isWin = String(java.lang.System.getProperty("os.name")).match(/Windows/)
910
if (io.fileExists(expr)) {
10-
if (!expr.endsWith(".js")) isoJob = true
11+
if (!expr.endsWith(".js")) {
12+
if (expr.endsWith(".yaml") || expr.endsWith(".json") || expr.endsWith(".yml"))
13+
isoJob = true
14+
else
15+
isoafp = true
16+
}
1117
if (io.readFileString(expr).replace(/\n/g, "").trim().substring(0, 2) == "#!")
1218
logWarn("Shebang entry on file '" + expr + "' detected. Ignoring request.");
1319
else {
14-
io.writeFileString(expr, templify((isoJob ? tmplJ : tmpl), {
20+
io.writeFileString(expr, templify((isoJob ? tmplJ : (isoafp ? tmplP : tmpl)), {
1521
openAFPath: getOpenAFPath()
1622
}) + io.readFileString(expr));
1723
if (!isWin) $sh("chmod u+x " + expr)
1824
.prefix("chmod")
1925
.get(0)
20-
log("Pre-appended " + (isoJob ? "oJob" : "OpenAF") + " shebang instructions to file: " + expr);
21-
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");
26+
log("Pre-appended " + (isoJob ? "oJob" : (isoafp ? "oafp" : "OpenAF")) + " shebang instructions to file: " + expr);
27+
if (!isoJob && !isoafp) {
28+
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");
29+
}
2230
}
2331
} else {
2432
// No file exists

js/genScripts.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ var winJobBat = generateWinJobBat();
334334
var winConsoleBat = generateWinConsoleBat();
335335
//var winConsolePSBat = generateWinConsolePSBat();
336336

337-
var unixScript, unixSB, unixSBoJob, unixPackScript, unixJobScript, unixConsoleScript, unixUpdateScript, unixOAFPScript
337+
var unixScript, unixSB, unixSBoJob, unixSBoafp, unixPackScript, unixJobScript, unixConsoleScript, unixUpdateScript, unixOAFPScript
338338

339339
//if (windows == 0) {
340340
unixScript = generateUnixScript("\"$@\"")
@@ -344,6 +344,7 @@ var unixScript, unixSB, unixSBoJob, unixPackScript, unixJobScript, unixConsoleSc
344344
unixJobScript = generateUnixScript("--ojob -e \"$SCRIPT $ARGS\"", true)
345345
unixConsoleScript = generateUnixScript("--console \"$@\"", __, __, true)
346346
unixOAFPScript = generateUnixScript("-c \"load(getOpenAFJar()+'::js/oafp.js')\" -e \"$ARGS\"")
347+
unixSBoafp = generateUnixScript("-c \"load(getOpenAFJar()+'::js/oafp.js')\" -e \"_shebang=true $OAFP_ARGS $ARGS\"")
347348
unixUpdateScript = generateUnixScript("--update", void 0, __genScriptsUpdate);
348349
//}
349350

@@ -365,6 +366,7 @@ try {
365366
io.writeFileString(curDir + "/openaf-sb", unixSB);
366367
io.writeFileString(curDir + "/oaf-sb", unixSB);
367368
io.writeFileString(curDir + "/ojob-sb", unixSBoJob);
369+
io.writeFileString(curDir + "/oafp-sb", unixSBoafp)
368370
io.writeFileString(curDir + "/opack", unixPackScript);
369371
io.writeFileString(curDir + "/ojob", unixJobScript);
370372
io.writeFileString(curDir + "/openaf-console", unixConsoleScript);
@@ -382,6 +384,7 @@ if (windows == 0) {
382384
sh("chmod a+x " + curDir + "/openaf-sb", "", null, false);
383385
sh("chmod a+x " + curDir + "/oaf-sb", "", null, false);
384386
sh("chmod a+x " + curDir + "/ojob-sb", "", null, false);
387+
sh("chmod a+x " + curDir + "/oafp-sb", "", null, false)
385388
sh("chmod a+x " + curDir + "/opack", "", null, false);
386389
sh("chmod a+x " + curDir + "/ojob", "", null, false);
387390
sh("chmod a+x " + curDir + "/openaf-console", "", null, false);

0 commit comments

Comments
 (0)