Skip to content

Commit 8680c09

Browse files
committed
read rescript.json from nodejs side
1 parent 8786ba1 commit 8680c09

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

rescript

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ var path = require("path");
1313
var fs = require("fs");
1414
var bsc_exe = require("./scripts/bin_path").bsc_exe;
1515
var rescript_exe = require("./scripts/bin_path").rescript_exe;
16-
var bsconfig = "bsconfig.json";
1716

1817
var LAST_BUILD_START = 0;
1918
var LAST_FIRED_EVENT = 0;
@@ -28,12 +27,19 @@ var lockFileName = path.join(cwd, ".bsb.lock");
2827
process.env.BSB_PROJECT_ROOT = cwd;
2928
// console.log('BSB_PROJECT_ROOT:', process.env.BSB_PROJECT_ROOT)
3029

30+
var bsConfig = "bsconfig.json"
31+
var resConfig = "rescript.json";
32+
var resConfigFile = path.join(cwd, resConfig);
33+
if (!fs.existsSync(resConfigFile)) {
34+
resConfig = bsConfig;
35+
resConfigFile = path.join(cwd, bsConfig);
36+
}
37+
3138
// If the project uses gentype and uses custom file extension
3239
// via generatedFileExtension, ignore them in watch mode
33-
var bsConfigFile = path.join(cwd, bsconfig);
3440
var genTypeFileExtension = undefined;
3541

36-
if (fs.existsSync(bsConfigFile)) {
42+
if (fs.existsSync(resConfigFile)) {
3743
var genTypeConfig = require(bsConfigFile).gentypeconfig
3844
if (genTypeConfig) {
3945
genTypeFileExtension = genTypeConfig.generatedFileExtension
@@ -373,7 +379,7 @@ if (
373379
watch_generated = watch_config.generated;
374380
// close and remove all unused watchers
375381
watchers = watchers.filter(function (watcher) {
376-
if (watcher.dir === bsconfig) {
382+
if (watcher.dir === resConfig) {
377383
return true;
378384
} else if (watch_files.indexOf(watcher.dir) < 0) {
379385
dlog(`${watcher.dir} is no longer watched`);
@@ -583,7 +589,7 @@ if (
583589
}
584590
}
585591

586-
watchers.push({ watcher: fs.watch(bsconfig, on_change), dir: bsconfig });
592+
watchers.push({ watcher: fs.watch(resConfig, on_change), dir: resConfig });
587593
build(0);
588594
}
589595
}

0 commit comments

Comments
 (0)