Skip to content

Naming: rewatch -> rescript (user facing) #7606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 0 additions & 134 deletions rewatch/README.md

This file was deleted.

6 changes: 2 additions & 4 deletions rewatch/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use std::{ffi::OsString, ops::Deref};
use clap::{Args, Parser, Subcommand};
use clap_verbosity_flag::InfoLevel;

/// Rewatch is an alternative build system for the Rescript Compiler bsb (which uses Ninja internally). It strives
/// to deliver consistent and faster builds in monorepo setups with multiple packages, where the
/// default build system fails to pick up changed interfaces across multiple packages.
/// ReScript - Fast, Simple, Fully Typed JavaScript from the Future
#[derive(Parser, Debug)]
#[command(version)]
#[command(args_conflicts_with_subcommands = true)]
Expand Down Expand Up @@ -147,7 +145,7 @@ pub struct WatchArgs {

#[derive(Subcommand, Clone, Debug)]
pub enum Command {
/// Build using Rewatch
/// Build the project
Build(BuildArgs),
/// Build, then start a watcher
Watch(WatchArgs),
Expand Down
4 changes: 2 additions & 2 deletions rewatch/src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use sysinfo::{PidExt, System, SystemExt};
* that's running, when trying to aquire a lock, it checks wether that process is still running. If
* not, it rewrites the lockfile to have its own PID instead. */

pub static LOCKFILE: &str = "rewatch.lock";
pub static LOCKFILE: &str = "rescript.lock";

pub enum Error {
Locked(u32),
Expand All @@ -21,7 +21,7 @@ pub enum Error {
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let msg = match self {
Error::Locked(pid) => format!("Rewatch is already running. The process ID (PID) is {}", pid),
Error::Locked(pid) => format!("A ReScript build is already running. The process ID (PID) is {}", pid),
Error::ParsingLockfile(e) => format!(
"Could not parse lockfile: \n {} \n (try removing it and running the command again)",
e
Expand Down
2 changes: 1 addition & 1 deletion rewatch/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fn main() -> Result<()> {
fn get_lock(folder: &str) -> lock::Lock {
match lock::get(folder) {
lock::Lock::Error(error) => {
println!("Could not start Rewatch: {error}");
println!("Could not start ReScript build: {error}");
std::process::exit(1);
}
acquired_lock => acquired_lock,
Expand Down
5 changes: 3 additions & 2 deletions rewatch/src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::queue::*;
use futures_timer::Delay;
use notify::event::ModifyKind;
use notify::{Config, Error, Event, EventKind, RecommendedWatcher, RecursiveMode, Watcher};
use crate::lock::LOCKFILE;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::sync::Mutex;
Expand Down Expand Up @@ -109,8 +110,8 @@ async fn async_watch(
}

for event in events {
// if there is a file named rewatch.lock in the events path, we can quit the watcher
if let Some(_) = event.paths.iter().find(|path| path.ends_with("rewatch.lock")) {
// if there is a file named rescript.lock in the events path, we can quit the watcher
if let Some(_) = event.paths.iter().find(|path| path.ends_with(LOCKFILE)) {
match event.kind {
EventKind::Remove(_) => {
if show_progress {
Expand Down
12 changes: 6 additions & 6 deletions rewatch/tests/lock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ sleep 1
if rewatch clean &> /dev/null;
then
success "Repo Cleaned"
else
else
error "Error Cleaning Repo"
exit 1
fi

exit_watcher() {
exit_watcher() {
# kill watcher by removing lock file
rm lib/rewatch.lock
rm lib/rescript.lock
}

rewatch_bg watch > /dev/null 2>&1 &
success "Watcher Started"

sleep 2

if rewatch build | grep 'Could not start Rewatch:' &> /dev/null;
if rewatch build | grep 'Could not start ReScript build:' &> /dev/null;
then
success "Lock is correctly set"
exit_watcher
else
else
error "Not setting lock correctly"
exit_watcher
exit 1
Expand All @@ -41,7 +41,7 @@ success "Watcher Started"

sleep 2

if cat tmp.txt | grep 'Could not start Rewatch:' &> /dev/null;
if cat tmp.txt | grep 'Could not start ReScript build:' &> /dev/null;
then
error "Lock not removed correctly"
exit_watcher
Expand Down
14 changes: 7 additions & 7 deletions rewatch/tests/watch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ bold "Test: It should watch"
if rewatch clean &> /dev/null;
then
success "Repo Cleaned"
else
else
error "Error Cleaning Repo"
exit 1
fi

exit_watcher() {
exit_watcher() {
# kill watcher by removing lock file
rm lib/rewatch.lock
rm lib/rescript.lock
}

rewatch_bg watch > /dev/null 2>&1 &
Expand All @@ -23,10 +23,10 @@ echo 'Js.log("added-by-test")' >> ./packages/main/src/Main.res

sleep 2

if node ./packages/main/src/Main.mjs | grep 'added-by-test' &> /dev/null;
if node ./packages/main/src/Main.mjs | grep 'added-by-test' &> /dev/null;
then
success "Output is correct"
else
else
error "Output is incorrect"
exit_watcher
exit 1
Expand All @@ -38,10 +38,10 @@ replace '/Js.log("added-by-test")/d' ./packages/main/src/Main.res;

sleep 1

if git diff --exit-code ./
if git diff --exit-code ./
then
success "Adding and removing changes nothing"
else
else
error "Adding and removing changes left some artifacts"
exit_watcher
exit 1
Expand Down