Skip to content

Commit 914c6b4

Browse files
committed
add toogle command to do it automtically
1 parent 2c03a5c commit 914c6b4

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

jscomp/cleanlib.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
#!/usr/bin/env node
22
var cp = require('child_process')
33
var fs = require('fs')
4+
exports.run = function () {
5+
cp.execSync(`make clean`)
6+
if (fs.existsSync(`stdlib-406`)) {
7+
cp.execSync(`git clean -dfx stdlib-406`)
8+
}
49

5-
cp.execSync(`make clean`)
6-
if(fs.existsSync(`stdlib-406`)){
7-
cp.execSync(`git clean -dfx stdlib-406`)
10+
cp.execSync(`git clean -dfx stdlib-402 test others runtime`)
811
}
912

10-
cp.execSync(`git clean -dfx stdlib-402 test others runtime`)
11-
13+
if(require.main === module){
14+
run()
15+
}

jscomp/switch.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env node
2+
var fs = require('fs')
3+
var path = require('path')
4+
5+
6+
var clean = require('./cleanlib.js')
7+
function toggleMakefile() {
8+
var filename = path.join(__dirname,'Makefile.shared')
9+
var line = fs.readFileSync(filename,'utf8')
10+
var toggled = (line.split('\n').map(x => {
11+
if (x.startsWith('STDLIB')) {
12+
return '# ' + x
13+
} else if (x.startsWith('# STDLIB')) {
14+
return x.substring(2)
15+
}
16+
return x
17+
}).join('\n'))
18+
19+
fs.writeFileSync(filename, toggled, 'utf8')
20+
}
21+
function toggleSharedMakefile(){
22+
var filename = path.join(__dirname, 'test','Makefile')
23+
var line = fs.readFileSync(filename,'utf8')
24+
var toggled = (line.split('\n').map(x => {
25+
if(x.startsWith(' # ocaml_typedtree_test')){
26+
return ' ocaml_typedtree_test'
27+
} else {
28+
if (x.startsWith(' ocaml_typedtree_test')){
29+
return ' # ocaml_typedtree_test'
30+
}
31+
}
32+
return x
33+
})).join('\n')
34+
fs.writeFileSync(filename,toggled,'utf8')
35+
}
36+
37+
38+
toggleMakefile()
39+
toggleSharedMakefile()
40+
clean.run()
41+
42+

0 commit comments

Comments
 (0)