@@ -4,9 +4,9 @@ var child_process = require('child_process')
4
4
var fs = require ( 'fs' )
5
5
var path = require ( 'path' )
6
6
var os = require ( 'os' )
7
- var root = path . join ( __dirname , '..' )
7
+ var root = path . join ( __dirname , '..' )
8
8
var dest_bin = path . join ( root , 'lib' )
9
- var dest_lib = path . join ( root , 'lib' , 'ocaml' )
9
+ var dest_lib = path . join ( root , 'lib' , 'ocaml' )
10
10
11
11
12
12
var jscomp = path . join ( root , 'jscomp' )
@@ -16,89 +16,101 @@ var jscomp = path.join(root, 'jscomp')
16
16
/*
17
17
* It is weird reaname cause Busy resource or lock error
18
18
*/
19
- function copyFile ( file , target ) {
20
- var stat = fs . statSync ( file )
21
- fs . createReadStream ( file ) . pipe (
22
- fs . createWriteStream ( target ,
23
- { mode : stat . mode } ) )
24
-
19
+ function copyFile ( file , target ) {
20
+ var stat = fs . statSync ( file )
21
+ fs . createReadStream ( file ) . pipe (
22
+ fs . createWriteStream ( target ,
23
+ { mode : stat . mode } ) )
24
+
25
25
}
26
26
27
27
28
28
/**
29
- * @param {string } from
30
- * @param {string } to
29
+ * @param {string } from
30
+ * @param {string } to
31
31
*/
32
- function renameAsync ( from , to ) {
33
- console . log ( from , '----->' , to )
34
- // @ts -ignore
35
- fs . rename ( from , to )
36
- // fs.renameSync(from,to)
32
+ function renameAsync ( from , to ) {
33
+ console . log ( from , '----->' , to )
34
+ // @ts -ignore
35
+ fs . rename ( from , to )
36
+ // fs.renameSync(from,to)
37
37
38
38
}
39
39
40
40
/**
41
41
* @param {string } from
42
42
* @param {string } to
43
43
*/
44
- function poor_copy_sync ( from , to ) {
45
- console . log ( from , '----->' , to )
46
- fs . renameSync ( from , to )
47
- // fs.renameSync(from,to)
44
+ function poor_copy_sync ( from , to ) {
45
+ console . log ( from , '----->' , to )
46
+ fs . renameSync ( from , to )
47
+ // fs.renameSync(from,to)
48
48
49
49
}
50
50
51
51
/**
52
- * @param {string } dir
52
+ * @param {string } dir
53
53
* @param {string } dest_lib
54
54
*/
55
- function install_directory ( dir , dest_lib ) {
56
- var files = fs . readdirSync ( dir )
57
- files . forEach ( function ( file ) {
58
- var installed_fmt = [ '.cmt' , '.cmti' , '.cmj' , '.ml' , '.mli' , '.cmi' ]
59
- var format_file = path . parse ( file )
60
- if ( format_file &&
61
- ( installed_fmt . indexOf ( format_file . ext ) !== - 1 )
62
- ) {
63
- var from = path . join ( dir , file )
64
- var to = path . join ( dest_lib , file )
65
- renameAsync ( from , to )
66
- }
67
- } )
55
+ function install_directory ( dir , dest_lib ) {
56
+ var files = fs . readdirSync ( dir )
57
+ files . forEach ( function ( file ) {
58
+ var installed_fmt = [ '.cmt' , '.cmti' , '.cmj' , '.ml' , '.mli' , '.cmi' ]
59
+ var format_file = path . parse ( file )
60
+ if ( format_file &&
61
+ ( installed_fmt . indexOf ( format_file . ext ) !== - 1 )
62
+ ) {
63
+ var from = path . join ( dir , file )
64
+ var to = path . join ( dest_lib , file )
65
+ renameAsync ( from , to )
66
+ }
67
+ } )
68
68
69
69
}
70
- function install ( ) {
71
- if ( ! fs . existsSync ( dest_bin ) ) {
72
- fs . mkdirSync ( dest_bin )
73
- }
74
- if ( ! fs . existsSync ( dest_lib ) ) {
75
- fs . mkdirSync ( dest_lib )
76
- }
77
-
78
-
79
-
80
- var jscomp_runtime = path . join ( jscomp , 'runtime' )
81
-
82
- var files = fs . readdirSync ( jscomp_runtime )
83
- files . forEach ( function ( file ) {
84
- var format_file = path . parse ( file )
85
- var special_files = [ 'js' , 'js_unsafe' , 'js_internal' , 'js_null' , 'js_undefined' , 'js_typed_array' , 'caml_exceptions' , 'js_float' ]
86
- var installed_fmt = [ '.cmt' , '.cmti' , '.cmj' ]
87
- if (
88
- format_file &&
89
- ( ( special_files . indexOf ( format_file . name ) !== - 1 )
90
- ||
91
- ( installed_fmt . indexOf ( format_file . ext ) !== - 1 ) )
92
- ) {
93
- var from = path . join ( jscomp_runtime , file )
94
- var to = path . join ( dest_lib , file )
95
- renameAsync ( from , to )
70
+ function install ( ) {
71
+ if ( ! fs . existsSync ( dest_bin ) ) {
72
+ fs . mkdirSync ( dest_bin )
96
73
}
97
- } )
74
+ if ( ! fs . existsSync ( dest_lib ) ) {
75
+ fs . mkdirSync ( dest_lib )
76
+ }
77
+
78
+
98
79
99
- install_directory ( path . join ( jscomp , 'stdlib' ) , dest_lib )
100
- install_directory ( path . join ( jscomp , 'others' ) , dest_lib )
80
+ var jscomp_runtime = path . join ( jscomp , 'runtime' )
81
+
82
+ var files = fs . readdirSync ( jscomp_runtime )
83
+ files . forEach ( function ( file ) {
84
+ var format_file = path . parse ( file )
85
+ var special_files = [
86
+ 'js' ,
87
+ 'js_unsafe' ,
88
+ 'js_internal' ,
89
+ 'caml_exceptions' ,
90
+ 'js_null' ,
91
+ 'js_undefined' ,
92
+ 'js_exn' ,
93
+ 'js_int' ,
94
+ 'js_float' ,
95
+ 'js_typed_array'
96
+ ]
97
+ var installed_fmt = [ '.cmt' , '.cmti' , '.cmj' ]
98
+ if (
99
+ format_file &&
100
+ ( ( special_files . indexOf ( format_file . name ) !== - 1 )
101
+ ||
102
+ ( installed_fmt . indexOf ( format_file . ext ) !== - 1 ) )
103
+ // Always copy cmt* cmj*
104
+ ) {
105
+ var from = path . join ( jscomp_runtime , file )
106
+ var to = path . join ( dest_lib , file )
107
+ renameAsync ( from , to )
108
+ }
109
+ } )
110
+
111
+ install_directory ( path . join ( jscomp , 'stdlib' ) , dest_lib )
112
+ install_directory ( path . join ( jscomp , 'others' ) , dest_lib )
101
113
}
102
114
103
- exports . install = install ;
115
+ exports . install = install ;
104
116
exports . poor_copy_sync = poor_copy_sync ;
0 commit comments