Skip to content

Commit a0b8116

Browse files
committed
#14 made the scripts to be executable
1 parent d1e9a1a commit a0b8116

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

assembler.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,20 @@ def optimize_imports(assembled_content):
6464
return result
6565

6666

67-
entry_scripts = {"build.py": "rebuild.py",
68-
"ci_build.py": "ci_rebuild.py"}
67+
entry_scripts = {'build.py': 'rebuild.py',
68+
'ci_build.py': 'ci_rebuild.py'}
6969

7070
for script_name, output_name in entry_scripts.items():
7171
build_file_content = file_utils.read_file(script_name)
72-
imported_files = ["build"]
72+
imported_files = ['build']
7373

74-
assembled_content = ""
74+
assembled_content = ''
75+
76+
shebang = None
77+
if build_file_content.startswith('#!'):
78+
splitted_content = build_file_content.split('\n', 1)
79+
shebang = splitted_content[0]
80+
build_file_content = splitted_content[1]
7581

7682
next_content = build_file_content
7783
while next_content:
@@ -81,6 +87,9 @@ def optimize_imports(assembled_content):
8187
assembled_content = optimize_imports(assembled_content)
8288
assembled_content = string_utils.remove_empty_lines(assembled_content)
8389

84-
output_path = os.path.join("build", output_name)
90+
if shebang:
91+
assembled_content = shebang + '\n' + assembled_content
92+
93+
output_path = os.path.join('build', output_name)
8594
file_utils.write_file(output_path, assembled_content)
8695
file_utils.make_executable(output_path)

build.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python
2+
13
from __future__ import print_function
24

35
import os.path

ci_build.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python
2+
13
import os.path
24

35
import common

0 commit comments

Comments
 (0)