forked from reasonml/reason
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgradeSyntax.sh
executable file
·36 lines (31 loc) · 1.3 KB
/
upgradeSyntax.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
# Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
# First arg is old refmt
# Second arg is new refmt
# Third arg is printwidth
die () {
echo >&2 "$@"
exit 1
}
[ "$#" -eq 3 ] || die "\nERROR:\n 3 arguments required [ oldPathToReason, newPathToReason, printWidth ], $# provided\n"
find . | grep "\.re$" | xargs -0 node -e "\
process.argv[1].split('\n').filter(function(n){return n;}).forEach(function(filePath) { \
var binary = require('child_process').execSync('$1 ' + filePath + ' -print binary_reason');
var reformatted = require('child_process').execSync(
'$2 -use-stdin true -is-interface-pp false -parse binary_reason -print re -print-width $3 | sed -e \'s/ *\$//g\'',
{input: binary}
);
require('fs').writeFileSync(filePath, reformatted);
}); \
"
find . | grep "\.rei$" | xargs -0 node -e "\
process.argv[1].split('\n').filter(function(n){return n;}).forEach(function(filePath) { \
var binary = require('child_process').execSync('$1 ' + filePath + ' -print binary_reason');
var reformatted = require('child_process').execSync(
'$2 -use-stdin true -is-interface-pp true -parse binary_reason -print re -print-width $3 | sed -e \'s/ *\$//g\'',
{input: binary}
);
require('fs').writeFileSync(filePath, reformatted);
}); \
console.log('echo \"Completed!\"'); \
"