| skipped 84 lines |
85 | 85 | | None |
86 | 86 | | } |
87 | 87 | | |
| 88 | + | // Replace npm run / yarn / pnpm run with `dum` |
| 89 | + | fn replace_run_commands(script: &str) -> String { |
| 90 | + | let mut dum = "dum"; |
| 91 | + | let mut dum_run = "dum run"; |
| 92 | + | if cfg!(debug_assertions) { |
| 93 | + | dum = "target/debug/dum"; |
| 94 | + | dum_run = "target/debug/dum run"; |
| 95 | + | } |
| 96 | + | script |
| 97 | + | .replace("npm run", dum_run) |
| 98 | + | .replace("yarn run", dum_run) |
| 99 | + | .replace("pnpm run", dum_run) |
| 100 | + | .replace("npx", dum) |
| 101 | + | .replace("pnpx", dum) |
| 102 | + | .replace("yarn", dum) |
| 103 | + | } |
| 104 | + | |
88 | 105 | | pub fn run(app_args: &args::AppArgs) { |
89 | 106 | | if args::COMMANDS_TO_FORWARD.contains(&app_args.command.as_str()) { |
90 | 107 | | debug!("Running command {}", app_args.command); |
| skipped 100 lines |
191 | 208 | | Some(script.unwrap_or_default()) |
192 | 209 | | }); |
193 | 210 | | if npm_script.is_some() { |
194 | | - | let script = npm_script.unwrap(); |
| 211 | + | let script = replace_run_commands(&npm_script.unwrap()); |
195 | 212 | | println!( |
196 | 213 | | "{} {}", |
197 | 214 | | Purple.dimmed().paint("$"), |
| skipped 40 lines |