Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd2ed8e

Browse files
authored
Rewatch: plain output when not running in tty (#7970)
* Handle non-tty mode the same as snapshot mode* Remove --snapshot-output command line arg* Rename snapshot_output -> plain_output* CHANGELOG
1 parent10dca8f commitdd2ed8e

File tree

8 files changed

+64
-87
lines changed

8 files changed

+64
-87
lines changed

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
####:nail_care: Polish
2626

27+
- Rewatch: plain output when not running in tty.https://github.com/rescript-lang/rescript/pull/7970
28+
2729
####:house: Internal
2830

2931
#12.0.0-rc.2

‎rewatch/src/build.rs‎

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ pub fn initialize_build(
131131
filter:&Option<regex::Regex>,
132132
show_progress:bool,
133133
path:&Path,
134-
snapshot_output:bool,
134+
plain_output:bool,
135135
warn_error:Option<String>,
136136
) ->Result<BuildCommandState>{
137137
let project_context =ProjectContext::new(path)?;
138138
let compiler =get_compiler_info(&project_context)?;
139139

140-
if !snapshot_output && show_progress{
140+
if !plain_output && show_progress{
141141
print!("{} {}Building package tree...", style("[1/7]").bold().dim(),TREE);
142142
let _ =stdout().flush();
143143
}
@@ -149,7 +149,7 @@ pub fn initialize_build(
149149
let compiler_check =verify_compiler_info(&packages,&compiler);
150150

151151
if show_progress{
152-
ifsnapshot_output{
152+
ifplain_output{
153153
ifletCompilerCheckResult::CleanedPackagesDueToCompiler = compiler_check{
154154
// Snapshot-friendly output (no progress prefixes or emojis)
155155
println!("Cleaned previous build due to compiler update");
@@ -181,7 +181,7 @@ pub fn initialize_build(
181181

182182
let timing_source_files =Instant::now();
183183

184-
if !snapshot_output && show_progress{
184+
if !plain_output && show_progress{
185185
print!(
186186
"{} {}Finding source files...",
187187
style("[2/7]").bold().dim(),
@@ -194,7 +194,7 @@ pub fn initialize_build(
194194
packages::parse_packages(&mut build_state);
195195
let timing_source_files_elapsed = timing_source_files.elapsed();
196196

197-
if !snapshot_output && show_progress{
197+
if !plain_output && show_progress{
198198
println!(
199199
"{}{} {}Found source files in {:.2}s",
200200
LINE_CLEAR,
@@ -216,7 +216,7 @@ pub fn initialize_build(
216216
let compile_assets_state = read_compile_state::read(&mut build_state)?;
217217
let timing_compile_state_elapsed = timing_compile_state.elapsed();
218218

219-
if !snapshot_output && show_progress{
219+
if !plain_output && show_progress{
220220
println!(
221221
"{}{} {}Read compile state {:.2}s",
222222
LINE_CLEAR,
@@ -238,7 +238,7 @@ pub fn initialize_build(
238238
let timing_cleanup_elapsed = timing_cleanup.elapsed();
239239

240240
if show_progress{
241-
ifsnapshot_output{
241+
ifplain_output{
242242
println!("Cleaned {diff_cleanup}/{total_cleanup}")
243243
}else{
244244
println!(
@@ -268,29 +268,29 @@ pub enum IncrementalBuildErrorKind {
268268

269269
#[derive(Debug,Clone)]
270270
pubstructIncrementalBuildError{
271-
pubsnapshot_output:bool,
271+
pubplain_output:bool,
272272
pubkind:IncrementalBuildErrorKind,
273273
}
274274

275275
impl fmt::DisplayforIncrementalBuildError{
276276
fnfmt(&self,f:&mut fmt::Formatter) -> fmt::Result{
277277
match&self.kind{
278278
IncrementalBuildErrorKind::SourceFileParseError =>{
279-
ifself.snapshot_output{
279+
ifself.plain_output{
280280
write!(f,"{LINE_CLEAR} Could not parse Source Files",)
281281
}else{
282282
write!(f,"{LINE_CLEAR} {CROSS}Could not parse Source Files",)
283283
}
284284
}
285285
IncrementalBuildErrorKind::CompileError(Some(e)) =>{
286-
ifself.snapshot_output{
286+
ifself.plain_output{
287287
write!(f,"{LINE_CLEAR} Failed to Compile. Error: {e}",)
288288
}else{
289289
write!(f,"{LINE_CLEAR} {CROSS}Failed to Compile. Error: {e}",)
290290
}
291291
}
292292
IncrementalBuildErrorKind::CompileError(None) =>{
293-
ifself.snapshot_output{
293+
ifself.plain_output{
294294
write!(f,"{LINE_CLEAR} Failed to Compile. See Errors Above",)
295295
}else{
296296
write!(f,"{LINE_CLEAR} {CROSS}Failed to Compile. See Errors Above",)
@@ -307,11 +307,11 @@ pub fn incremental_build(
307307
show_progress:bool,
308308
only_incremental:bool,
309309
create_sourcedirs:bool,
310-
snapshot_output:bool,
310+
plain_output:bool,
311311
) ->Result<(),IncrementalBuildError>{
312312
logs::initialize(&build_state.packages);
313313
let num_dirty_modules = build_state.modules.values().filter(|m|is_dirty(m)).count()asu64;
314-
let pb =if !snapshot_output && show_progress{
314+
let pb =if !plain_output && show_progress{
315315
ProgressBar::new(num_dirty_modules)
316316
}else{
317317
ProgressBar::hidden()
@@ -334,7 +334,7 @@ pub fn incremental_build(
334334
match result_asts{
335335
Ok(_ast) =>{
336336
if show_progress{
337-
ifsnapshot_output{
337+
ifplain_output{
338338
println!("Parsed {num_dirty_modules} source files")
339339
}else{
340340
println!(
@@ -352,7 +352,7 @@ pub fn incremental_build(
352352
Err(err) =>{
353353
logs::finalize(&build_state.packages);
354354

355-
if !snapshot_output && show_progress{
355+
if !plain_output && show_progress{
356356
println!(
357357
"{}{} {}Error parsing source files in {:.2}s",
358358
LINE_CLEAR,
@@ -366,7 +366,7 @@ pub fn incremental_build(
366366
println!("{}",&err);
367367
returnErr(IncrementalBuildError{
368368
kind:IncrementalBuildErrorKind::SourceFileParseError,
369-
snapshot_output,
369+
plain_output,
370370
});
371371
}
372372
}
@@ -376,7 +376,7 @@ pub fn incremental_build(
376376
let timing_deps_elapsed = timing_deps.elapsed();
377377
current_step +=1;
378378

379-
if !snapshot_output && show_progress{
379+
if !plain_output && show_progress{
380380
println!(
381381
"{}{} {}Collected deps in {:.2}s",
382382
LINE_CLEAR,
@@ -400,7 +400,7 @@ pub fn incremental_build(
400400
};
401401

402402
let start_compiling =Instant::now();
403-
let pb =if !snapshot_output && show_progress{
403+
let pb =if !plain_output && show_progress{
404404
ProgressBar::new(build_state.modules.len().try_into().unwrap())
405405
}else{
406406
ProgressBar::hidden()
@@ -422,7 +422,7 @@ pub fn incremental_build(
422422
)
423423
.map_err(|e|IncrementalBuildError{
424424
kind:IncrementalBuildErrorKind::CompileError(Some(e.to_string())),
425-
snapshot_output,
425+
plain_output,
426426
})?;
427427

428428
let compile_duration = start_compiling.elapsed();
@@ -434,7 +434,7 @@ pub fn incremental_build(
434434
pb.finish();
435435
if !compile_errors.is_empty(){
436436
if show_progress{
437-
ifsnapshot_output{
437+
ifplain_output{
438438
println!("Compiled {num_compiled_modules} modules")
439439
}else{
440440
println!(
@@ -458,11 +458,11 @@ pub fn incremental_build(
458458
}
459459
Err(IncrementalBuildError{
460460
kind:IncrementalBuildErrorKind::CompileError(None),
461-
snapshot_output,
461+
plain_output,
462462
})
463463
}else{
464464
if show_progress{
465-
ifsnapshot_output{
465+
ifplain_output{
466466
println!("Compiled {num_compiled_modules} modules")
467467
}else{
468468
println!(
@@ -539,7 +539,7 @@ pub fn build(
539539
show_progress:bool,
540540
no_timing:bool,
541541
create_sourcedirs:bool,
542-
snapshot_output:bool,
542+
plain_output:bool,
543543
warn_error:Option<String>,
544544
) ->Result<BuildCommandState>{
545545
let default_timing:Option<std::time::Duration> =if no_timing{
@@ -553,7 +553,7 @@ pub fn build(
553553
filter,
554554
show_progress,
555555
path,
556-
snapshot_output,
556+
plain_output,
557557
warn_error,
558558
)
559559
.map_err(|e|anyhow!("Could not initialize build. Error: {e}"))?;
@@ -565,10 +565,10 @@ pub fn build(
565565
show_progress,
566566
false,
567567
create_sourcedirs,
568-
snapshot_output,
568+
plain_output,
569569
){
570570
Ok(_) =>{
571-
if !snapshot_output && show_progress{
571+
if !plain_output && show_progress{
572572
let timing_total_elapsed = timing_total.elapsed();
573573
println!(
574574
"\n{}{}Finished Compilation in {:.2}s",

‎rewatch/src/build/clean.rs‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,13 @@ pub fn cleanup_after_build(build_state: &BuildCommandState) {
331331
});
332332
}
333333

334-
pubfnclean(path:&Path,show_progress:bool,snapshot_output:bool) ->Result<()>{
334+
pubfnclean(path:&Path,show_progress:bool,plain_output:bool) ->Result<()>{
335335
let project_context =ProjectContext::new(path)?;
336336
let compiler_info = build::get_compiler_info(&project_context)?;
337337
let packages = packages::make(&None,&project_context, show_progress)?;
338338

339339
let timing_clean_compiler_assets =Instant::now();
340-
if !snapshot_output && show_progress{
340+
if !plain_output && show_progress{
341341
print!(
342342
"{} {}Cleaning compiler assets...",
343343
style("[1/2]").bold().dim(),
@@ -347,12 +347,12 @@ pub fn clean(path: &Path, show_progress: bool, snapshot_output: bool) -> Result<
347347
};
348348

349349
for(_, package)in&packages{
350-
clean_package(show_progress,snapshot_output, package)
350+
clean_package(show_progress,plain_output, package)
351351
}
352352

353353
let timing_clean_compiler_assets_elapsed = timing_clean_compiler_assets.elapsed();
354354

355-
if !snapshot_output && show_progress{
355+
if !plain_output && show_progress{
356356
println!(
357357
"{}{} {}Cleaned compiler assets in {:.2}s",
358358
LINE_CLEAR,
@@ -367,7 +367,7 @@ pub fn clean(path: &Path, show_progress: bool, snapshot_output: bool) -> Result<
367367
letmut build_state =BuildState::new(project_context, packages, compiler_info);
368368
packages::parse_packages(&mut build_state);
369369
let root_config = build_state.get_root_config();
370-
let suffix_for_print =ifsnapshot_output || !show_progress{
370+
let suffix_for_print =ifplain_output || !show_progress{
371371
String::new()
372372
}else{
373373
match root_config.package_specs{
@@ -390,7 +390,7 @@ pub fn clean(path: &Path, show_progress: bool, snapshot_output: bool) -> Result<
390390
}
391391
};
392392

393-
if !snapshot_output && show_progress{
393+
if !plain_output && show_progress{
394394
println!(
395395
"{} {}Cleaning {} files...",
396396
style("[2/2]").bold().dim(),
@@ -403,7 +403,7 @@ pub fn clean(path: &Path, show_progress: bool, snapshot_output: bool) -> Result<
403403
clean_source_files(&build_state, root_config);
404404
let timing_clean_mjs_elapsed = timing_clean_mjs.elapsed();
405405

406-
if !snapshot_output && show_progress{
406+
if !plain_output && show_progress{
407407
println!(
408408
"{}{} {}Cleaned {} files in {:.2}s",
409409
LINE_CLEAR,
@@ -418,9 +418,9 @@ pub fn clean(path: &Path, show_progress: bool, snapshot_output: bool) -> Result<
418418
Ok(())
419419
}
420420

421-
pubfnclean_package(show_progress:bool,snapshot_output:bool,package:&Package){
421+
pubfnclean_package(show_progress:bool,plain_output:bool,package:&Package){
422422
if show_progress{
423-
ifsnapshot_output{
423+
ifplain_output{
424424
println!("Cleaning {}", package.name)
425425
}else{
426426
print!(

‎rewatch/src/cli.rs‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,6 @@ pub struct DevArg {
219219
pubdev:bool,
220220
}
221221

222-
#[derive(Args,Debug,Clone,Copy)]
223-
pubstructSnapshotOutputArg{
224-
/// simple output for snapshot testing
225-
#[arg(short, long, default_value ="false", num_args =0..=1)]
226-
pubsnapshot_output:bool,
227-
}
228-
229222
#[derive(Args,Debug,Clone)]
230223
pubstructBuildArgs{
231224
#[command(flatten)]
@@ -247,9 +240,6 @@ pub struct BuildArgs {
247240
#[arg(short, long, default_value_t =false, num_args =0..=1)]
248241
pubno_timing:bool,
249242

250-
#[command(flatten)]
251-
pubsnapshot_output:SnapshotOutputArg,
252-
253243
/// Watch mode (deprecated, use `rescript watch` instead)
254244
#[arg(short, default_value_t =false, num_args =0..=1)]
255245
pubwatch:bool,
@@ -418,9 +408,6 @@ pub struct WatchArgs {
418408
#[command(flatten)]
419409
pubdev:DevArg,
420410

421-
#[command(flatten)]
422-
pubsnapshot_output:SnapshotOutputArg,
423-
424411
/// Warning numbers and whether to turn them into errors
425412
///
426413
/// This flag overrides any warning configuration in rescript.json.
@@ -438,7 +425,6 @@ impl From<BuildArgs> for WatchArgs {
438425
after_build: build_args.after_build,
439426
create_sourcedirs: build_args.create_sourcedirs,
440427
dev: build_args.dev,
441-
snapshot_output: build_args.snapshot_output,
442428
warn_error: build_args.warn_error,
443429
}
444430
}
@@ -455,9 +441,6 @@ pub enum Command {
455441
#[command(flatten)]
456442
folder:FolderArg,
457443

458-
#[command(flatten)]
459-
snapshot_output:SnapshotOutputArg,
460-
461444
#[command(flatten)]
462445
dev:DevArg,
463446
},
@@ -531,11 +514,3 @@ impl Deref for DevArg {
531514
&self.dev
532515
}
533516
}
534-
535-
implDerefforSnapshotOutputArg{
536-
typeTarget =bool;
537-
538-
fnderef(&self) ->&Self::Target{
539-
&self.snapshot_output
540-
}
541-
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp