Skip to content

Commit de61ef8

Browse files
authored
Merge pull request #2245 from BuckleScript/fix_2207
fix #2207
2 parents cd40811 + 4180b7f commit de61ef8

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

scripts/install.js

+27-24
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,24 @@ function tryToProvideOCamlCompiler() {
114114
}
115115
}
116116

117-
function non_windows_npm_release() {
117+
// copy all [*.sys_extension] files into [*.exe]
118+
function copyBinToExe() {
119+
var indeed_windows_release = 0
120+
fs.readdirSync(lib_dir).forEach(function (f) {
121+
var last_index = f.lastIndexOf(sys_extension)
122+
if (last_index !== -1) {
123+
var new_file = f.slice(0, - sys_extension.length) + ".exe"
124+
build_util.poor_copy_sync(path.join(lib_dir, f), path.join(lib_dir, new_file));
125+
// we do have .win file which means windows npm release
126+
++indeed_windows_release
127+
}
118128

119-
if (checkPrebuilt()) {
120-
child_process.execSync(make + " libs && " + make + " install", root_dir_config)
121-
} else {
122-
tryToProvideOCamlCompiler()
123-
child_process.execSync(make + " world && " + make + " install", root_dir_config)
124-
}
129+
})
130+
return indeed_windows_release > 1
125131
}
132+
126133
function checkPrebuilt() {
127134
try {
128-
if(fs.existsSync(path.join(lib_dir,'bsc.exe'))){
129-
console.log('Found bsc.exe, assume it was already built')
130-
return true // already built before
131-
}
132135
var version = child_process.execFileSync(path.join(lib_dir, 'bsc' + sys_extension), ['-v'])
133136
console.log("checkoutput:", String(version))
134137
return copyBinToExe()
@@ -138,20 +141,21 @@ function checkPrebuilt() {
138141
}
139142
}
140143

141-
function copyBinToExe() {
142-
var indeed_windows_release = 0
143-
fs.readdirSync(lib_dir).forEach(function (f) {
144-
var last_index = f.lastIndexOf(sys_extension)
145-
if (last_index !== -1) {
146-
var new_file = f.slice(0, - sys_extension.length) + ".exe"
147-
build_util.poor_copy_sync(path.join(lib_dir, f), path.join(lib_dir, new_file));
148-
// we do have .win file which means windows npm release
149-
++indeed_windows_release
150-
}
151144

152-
})
153-
return indeed_windows_release > 1
145+
146+
function non_windows_npm_release() {
147+
if (fs.existsSync(path.join(lib_dir, 'bsc.exe'))) {
148+
console.log('Found bsc.exe, assume it was already built')
149+
return true // already built before
150+
}
151+
if (checkPrebuilt()) {
152+
child_process.execSync(make + " libs && " + make + " install", root_dir_config)
153+
} else {
154+
tryToProvideOCamlCompiler()
155+
child_process.execSync(make + " world && " + make + " install", root_dir_config)
156+
}
154157
}
158+
155159
var build_util = require('./build_util.js')
156160

157161
setUpNinja()
@@ -161,7 +165,6 @@ if (is_windows) {
161165
path.join(__dirname, 'win_build.bat'),
162166
{ cwd: path.join(root_dir, 'jscomp'), stdio: [0, 1, 2] }
163167
)
164-
// clean.clean()
165168
console.log("Installing")
166169
build_util.install()
167170
} else {

0 commit comments

Comments
 (0)