Skip to content

Commit

Permalink
Fix --executable scripts when created with non-installed ursa
Browse files Browse the repository at this point in the history
Give an error if we try to create an executable script with the
test-run.sh development shim.

Also uncomment some tear-down in the test of executable scripts.
  • Loading branch information
rrthomas committed Jul 26, 2024
1 parent c71862a commit c2f91f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/ursa/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ async function compileCommand(args: Args) {
let output = ''
if (args.target === 'ark') {
if (args.executable) {
output += '#!/usr/bin/env -S ursa --syntax=json run\n'
if (path.basename(process.argv[1]) === 'cli.ts') {
throw new Error('Cannot create executable from test-run.sh')
}
output += `#!/usr/bin/env -S ${process.argv0} --no-warnings ${process.argv[1]} --syntax=json run\n`
}
output += serializeVal(exp)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/ursa/examples.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ursaTest('Anagrams', 'rosettacode/Anagrams', ['rosettacode/unixdict.txt'])
test('Executable scripts', async (t) => {
for (const target of ['ark', 'js']) {
const tempExecFile = tmp.fileSync({discardDescriptor: true})
// t.teardown(() => tempExecFile.removeCallback())
t.teardown(() => tempExecFile.removeCallback())
await execa(ursaCommand, [
`--target=${target}`,
'compile', '--executable', 'test/advent-of-code-2023-day-25.ursa',
Expand Down

0 comments on commit c2f91f7

Please sign in to comment.