import subprocess
def asrun(ascript):
"Run the given AppleScript and return the standard output."
osa = subprocess.run(['/usr/bin/osascript', '-'], input=ascript, text=True, capture_output=True)
if osa.returncode == 0:
return osa.stdout.rstrip()
else:
raise ChildProcessError(f'AppleScript: {osa.stderr.rstrip()}')
scriptNodeVersion = '''
tell application "Terminal"
activate
do script "cd '{}'"
do script "node -v" in front window
end tell
'''.format(project.folder)
asrun(scriptNodeVersion)
In case anybody needs at some to run AppleScript scripts from TD in macOS.
The one above will just open a Terminal window, cd to the projects folder and check the installed node.js version.