forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PR cosmos#105: Compile Typescript
- Loading branch information
Showing
10 changed files
with
109 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ | |
else: | ||
print('Found cycles!') | ||
print(cycles) | ||
sys.exit(1) | ||
|
||
print('Drawing dependency graph...') | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python | ||
|
||
import re, os, sys, subprocess, glob | ||
|
||
specs = [f.path for f in os.scandir('./spec') if f.is_dir()] | ||
files = [f.path for spec in specs for f in os.scandir(spec) if f.is_file() and f.path[-3:] == '.md'] | ||
|
||
requires_regex = re.compile('requires: (.*)\n') | ||
|
||
def temp_filename(): | ||
return subprocess.check_output(['mktemp'])[:-1] + bytes('.ts', 'utf-8') | ||
|
||
def extract_typescript(spec): | ||
temp = temp_filename() | ||
subprocess.check_output(['/bin/bash', '-c', b'cat ' + bytes(spec, 'utf-8') + b' | codedown typescript > ' + temp]) | ||
return temp | ||
|
||
for fn in files: | ||
print('Checking syntax in {}'.format(fn)) | ||
temp = extract_typescript(fn) | ||
|
||
print('Running tslint...') | ||
output = subprocess.check_output(['tslint', '-c', './scripts/tslint.json', temp]) | ||
if output != b'': | ||
sys.exit(1) | ||
|
||
print('Reading dependencies of {}'.format(fn)) | ||
data = open(fn).read() | ||
requires = [int(num) for line in requires_regex.findall(data) for num in line.split(', ')] | ||
|
||
print('Dependencies: {}'.format(requires)) | ||
final = temp_filename() | ||
|
||
for dep in requires: | ||
spec = glob.glob('./spec/ics-' + str(dep).zfill(3) + '-*')[0] + '/README.md' | ||
newTemp = extract_typescript(spec) | ||
print('Concatenating dependency on ICS {}'.format(dep)) | ||
subprocess.check_call(['/bin/bash', '-c', b'cat ' + newTemp + b' >> ' + final]) | ||
subprocess.check_call(['/bin/bash', '-c', b'echo -e "\n" >> ' + final]) | ||
|
||
subprocess.check_call(['/bin/bash', '-c', b'cat ' + temp + b' >> ' + final]) | ||
|
||
res = subprocess.run(['tsc', '--lib', 'es6', '--downlevelIteration', final]) | ||
|
||
if res.returncode != 0: | ||
print(res) | ||
# sys.exit(1) | ||
|
||
subprocess.check_call(['rm', temp]) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters