Skip to content

Commit 8786ba1

Browse files
committed
Revert "pass config to -project arg"
This reverts commit a012c34.
1 parent c2deaa0 commit 8786ba1

File tree

5 files changed

+30
-64
lines changed

5 files changed

+30
-64
lines changed

jscomp/bsb_exe/rescript_main.ml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ let () = Bsb_log.setup ()
2626

2727
let separator = "--"
2828

29-
(* FIXME: should be swapped in v12 *)
30-
let project_path = ref "bsconfig.json"
31-
3229
let watch_mode = ref false
3330

3431
let make_world = ref false
@@ -151,10 +148,9 @@ let build_subcommand ~start argv argv_len =
151148
( "-regen",
152149
unit_set_spec force_regenerate,
153150
"*internal* \n\
154-
Always regenerate build.ninja no matter rescript.json is changed or \
151+
Always regenerate build.ninja no matter bsconfig.json is changed or \
155152
not" );
156153
("-verbose", call_spec Bsb_log.verbose, "Set the output to be verbose");
157-
("-project", string_set_spec project_path, "Project file (rescript.json) path");
158154
|]
159155
failed_annon;
160156

rescript

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ 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";
1617

1718
var LAST_BUILD_START = 0;
1819
var LAST_FIRED_EVENT = 0;
@@ -27,23 +28,13 @@ var lockFileName = path.join(cwd, ".bsb.lock");
2728
process.env.BSB_PROJECT_ROOT = cwd;
2829
// console.log('BSB_PROJECT_ROOT:', process.env.BSB_PROJECT_ROOT)
2930

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-
3831
// If the project uses gentype and uses custom file extension
3932
// via generatedFileExtension, ignore them in watch mode
33+
var bsConfigFile = path.join(cwd, bsconfig);
4034
var genTypeFileExtension = undefined;
4135

42-
if (fs.existsSync(resConfigFile)) {
43-
if (resConfig === bsConfig) {
44-
console.warn("bsconfig.json is deprecated. Use rescript.json instead.");
45-
}
46-
var genTypeConfig = require(resConfigFile).gentypeconfig
36+
if (fs.existsSync(bsConfigFile)) {
37+
var genTypeConfig = require(bsConfigFile).gentypeconfig
4738
if (genTypeConfig) {
4839
genTypeFileExtension = genTypeConfig.generatedFileExtension
4940
}
@@ -258,25 +249,29 @@ if (
258249
require("./scripts/rescript_format.js").main(
259250
process.argv.slice(3),
260251
rescript_exe,
261-
bsc_exe,
262-
resConfigFile
252+
bsc_exe
253+
);
254+
break;
255+
case "dump":
256+
require("./scripts/rescript_dump.js").main(
257+
process.argv.slice(3),
258+
rescript_exe,
259+
bsc_exe
263260
);
264261
break;
265262
case "dump":
266263
require("./scripts/rescript_dump.js").main(
267264
process.argv.slice(3),
268265
rescript_exe,
269-
bsc_exe,
270-
resConfigFile
266+
bsc_exe
271267
);
272268
break;
273269
case "convert":
274270
// Todo
275271
require("./scripts/rescript_convert.js").main(
276272
process.argv.slice(3),
277273
rescript_exe,
278-
bsc_exe,
279-
resConfigFile
274+
bsc_exe
280275
);
281276
break;
282277
case "-h":
@@ -317,11 +312,6 @@ if (
317312
}
318313

319314
verbose = delegate_args.includes("-verbose");
320-
321-
if (!delegate_args.includes("-config")) {
322-
delegate_args = delegate_args.concat(["-project", resConfigFile]);
323-
}
324-
325315
/**
326316
* @type {child_process.ChildProcess}
327317
*/
@@ -383,7 +373,7 @@ if (
383373
watch_generated = watch_config.generated;
384374
// close and remove all unused watchers
385375
watchers = watchers.filter(function (watcher) {
386-
if (watcher.dir === resConfig) {
376+
if (watcher.dir === bsconfig) {
387377
return true;
388378
} else if (watch_files.indexOf(watcher.dir) < 0) {
389379
dlog(`${watcher.dir} is no longer watched`);
@@ -593,7 +583,7 @@ if (
593583
}
594584
}
595585

596-
watchers.push({ watcher: fs.watch(resConfig, on_change), dir: resConfig });
586+
watchers.push({ watcher: fs.watch(bsconfig, on_change), dir: bsconfig });
597587
build(0);
598588
}
599589
}

scripts/rescript_convert.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function handleOneFile(file, bsc_exe) {
6767
* @param {string} rescript_exe
6868
* @param {string} bsc_exe
6969
*/
70-
function main(argv, rescript_exe, bsc_exe, project_path) {
70+
function main(argv, rescript_exe, bsc_exe) {
7171
try {
7272
/**
7373
* @type {string[]}
@@ -88,7 +88,7 @@ function main(argv, rescript_exe, bsc_exe, project_path) {
8888
// TODO: check the rest arguments
8989
var output = child_process.spawnSync(
9090
rescript_exe,
91-
["info", "-list-files", "-project", project_path],
91+
["info", "-list-files"],
9292
{
9393
encoding: "utf-8",
9494
}

scripts/rescript_dump.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var specs = [];
1515
* @param {string} rescript_exe
1616
* @param {string} bsc_exe
1717
*/
18-
function main(argv, rescript_exe, bsc_exe, project_path) {
18+
function main(argv, rescript_exe, bsc_exe) {
1919
var target;
2020
arg.parse_exn(dump_usage, argv, specs, xs => {
2121
if (xs.length !== 1) {
@@ -30,11 +30,9 @@ function main(argv, rescript_exe, bsc_exe, project_path) {
3030
process.exit(2);
3131
}
3232

33-
var output = child_process.spawnSync(
34-
rescript_exe,
35-
["build", "-project", project_path, "--", target],
36-
{ encoding: "utf-8" }
37-
);
33+
var output = child_process.spawnSync(rescript_exe, ["build", "--", target], {
34+
encoding: "utf-8",
35+
});
3836
if (output.status !== 0) {
3937
console.log(output.stdout);
4038
console.error(output.stderr);

scripts/rescript_format.js

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,15 @@ async function readStdin() {
7373
* @param {(x: string) => boolean} isSupportedFile
7474
* @param {boolean} checkFormatting
7575
*/
76-
async function formatFiles(
77-
files,
78-
bsc_exe,
79-
project_path,
80-
isSupportedFile,
81-
checkFormatting
82-
) {
76+
async function formatFiles(files, bsc_exe, isSupportedFile, checkFormatting) {
8377
var incorrectlyFormattedFiles = 0;
8478
try {
8579
const _promises = await Promise.all(
8680
files.map(async file => {
8781
if (isSupportedFile(file)) {
8882
const flags = checkFormatting
89-
? ["-project", project_path, "-format", file]
90-
: ["-project", project_path, "-o", file, "-format", file];
83+
? ["-format", file]
84+
: ["-o", file, "-format", file];
9185
const { stdout } = await asyncExecFile(bsc_exe, flags);
9286
if (check.val) {
9387
const original = await asyncFs.readFile(file, "utf-8");
@@ -121,7 +115,7 @@ async function formatFiles(
121115
* @param {string} rescript_exe
122116
* @param {string} bsc_exe
123117
*/
124-
async function main(argv, rescript_exe, bsc_exe, project_path) {
118+
async function main(argv, rescript_exe, bsc_exe) {
125119
var isSupportedFile = hasExtension(formattedFileExtensions);
126120
var isSupportedStd = hasExtension(formattedStdExtensions);
127121

@@ -166,13 +160,7 @@ async function main(argv, rescript_exe, bsc_exe, project_path) {
166160
process.exit(2);
167161
}
168162
files = output.stdout.split("\n").map(x => x.trim());
169-
await formatFiles(
170-
files,
171-
bsc_exe,
172-
project_path,
173-
isSupportedFile,
174-
check.val
175-
);
163+
await formatFiles(files, bsc_exe, isSupportedFile, check.val);
176164
} else if (use_stdin) {
177165
if (check.val) {
178166
console.error("format -stdin cannot be used with -check flag");
@@ -195,7 +183,7 @@ async function main(argv, rescript_exe, bsc_exe, project_path) {
195183
process.addListener("exit", () => fs.unlinkSync(filename));
196184
child_process.execFile(
197185
bsc_exe,
198-
["-project", project_path, "-format", filename],
186+
["-format", filename],
199187
(error, stdout, stderr) => {
200188
if (error === null) {
201189
process.stdout.write(stdout);
@@ -226,13 +214,7 @@ async function main(argv, rescript_exe, bsc_exe, project_path) {
226214
process.exit(2);
227215
}
228216
}
229-
await formatFiles(
230-
files,
231-
bsc_exe,
232-
project_path,
233-
isSupportedFile,
234-
check.val
235-
);
217+
await formatFiles(files, bsc_exe, isSupportedFile, check.val);
236218
}
237219
} catch (e) {
238220
if (e instanceof arg.ArgError) {

0 commit comments

Comments
 (0)