Skip to content

Commit 82f708a

Browse files
committed
fix: use createTempPath for Asm
1 parent bb74d13 commit 82f708a

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

lib/grammars/index.js

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -569,15 +569,21 @@ const OtherGrammars = {
569569
"File Based": {
570570
command: "bash",
571571
args({ filepath }) {
572-
const args = (() => {
573-
switch (arch) {
574-
case "x32":
575-
return `nasm -f elf '${filepath}' -o /tmp/asm.out.o && ld -m elf_i386 /tmp/asm.out.o -o /tmp/asm.out && /tmp/asm.out`
576-
case "x64":
577-
return `nasm -f elf64 '${filepath}' -o /tmp/asm.out.o && ld /tmp/asm.out.o -o /tmp/asm.out && /tmp/asm.out`
572+
const tempOutOFile = GrammarUtils.createTempPath("asm-", ".out.o")
573+
const tempOutFile = GrammarUtils.createTempPath("asm-", ".out")
574+
let cmadArgs = ""
575+
switch (arch) {
576+
case "x32":
577+
cmadArgs = `nasm -f elf '${filepath}' -o ${tempOutOFile} && ld -m elf_i386 ${tempOutOFile} -o ${tempOutFile} && ${tempOutFile}`
578+
break
579+
case "x64":
580+
cmadArgs = `nasm -f elf64 '${filepath}' -o ${tempOutOFile} && ld ${tempOutOFile} -o ${tempOutFile} && ${tempOutFile}`
581+
break
582+
default: {
583+
atom.notifications.addError(`Not supported on ${arch}`)
578584
}
579-
})()
580-
return ["-c", args]
585+
}
586+
return ["-c", cmadArgs]
581587
},
582588
},
583589

@@ -586,15 +592,21 @@ const OtherGrammars = {
586592
args(context) {
587593
const code = context.getCode()
588594
const tmpFile = GrammarUtils.createTempFileWithCode(code, ".asm")
589-
const args = (() => {
590-
switch (arch) {
591-
case "x32":
592-
return `nasm -f elf '${tmpFile}' -o /tmp/asm.out.o && ld -m elf_i386 /tmp/asm.out.o -o /tmp/asm.out && /tmp/asm.out`
593-
case "x64":
594-
return `nasm -f elf64 '${tmpFile}' -o /tmp/asm.out.o && ld /tmp/asm.out.o -o /tmp/asm.out && /tmp/asm.out`
595+
const tempOutOFile = GrammarUtils.createTempPath("asm-", ".out.o")
596+
const tempOutFile = GrammarUtils.createTempPath("asm-", ".out")
597+
let cmdArgs = ""
598+
switch (arch) {
599+
case "x32":
600+
cmdArgs = `nasm -f elf '${tmpFile}' -o ${tempOutOFile} && ld -m elf_i386 ${tempOutOFile} -o ${tempOutFile} && ${tempOutFile}`
601+
break
602+
case "x64":
603+
cmdArgs = `nasm -f elf64 '${tmpFile}' -o ${tempOutOFile} && ld ${tempOutOFile} -o ${tempOutFile} && ${tempOutFile}`
604+
break
605+
default: {
606+
atom.notifications.addError(`Not supported on ${arch}`)
595607
}
596-
})()
597-
return ["-c", args]
608+
}
609+
return ["-c", cmdArgs]
598610
},
599611
},
600612
},

0 commit comments

Comments
 (0)