MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / make_js_executable

Function make_js_executable

tools/link.py:458–473  ·  view source on GitHub ↗
(script)

Source from the content-addressed store, hash-verified

456
457
458def make_js_executable(script):
459 src = read_file(script)
460
461 # By default, the resulting script will run under the version of node in the PATH.
462 if settings.EXECUTABLE == 1:
463 settings.EXECUTABLE = '/usr/bin/env node'
464
465 logger.debug(f'adding `#!` to JavaScript file: {settings.EXECUTABLE}')
466 # add shebang
467 with open(script, 'w', encoding='utf-8') as f:
468 f.write(f'#!{settings.EXECUTABLE}\n')
469 f.write(src)
470 try:
471 os.chmod(script, stat.S_IMODE(os.stat(script).st_mode) | stat.S_IXUSR) # make executable
472 except OSError:
473 pass # can fail if e.g. writing the executable to /dev/null
474
475
476def do_split_module(wasm_file, options):

Callers 1

phase_final_emittingFunction · 0.85

Calls 3

read_fileFunction · 0.70
openFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected