MCPcopy Index your code
hub / github.com/AI45Lab/Code / node_verification_preset

Function node_verification_preset

core/src/verification.rs:327–366  ·  view source on GitHub ↗
(workspace: &Path)

Source from the content-addressed store, hash-verified

325}
326
327fn node_verification_preset(workspace: &Path) -> Option<VerificationPreset> {
328 let package_json = std::fs::read_to_string(workspace.join("package.json")).ok()?;
329 let package: serde_json::Value = serde_json::from_str(&package_json).ok()?;
330 let scripts = package.get("scripts").and_then(|value| value.as_object())?;
331 let package_manager = detect_node_package_manager(workspace, &package);
332 let mut commands = Vec::new();
333
334 for (script, kind, description, required) in [
335 ("test", "test", "Run JavaScript tests", true),
336 (
337 "typecheck",
338 "type_check",
339 "Run JavaScript type checks",
340 false,
341 ),
342 ("lint", "lint", "Run JavaScript lint checks", false),
343 ] {
344 if scripts.contains_key(script) {
345 let command = node_script_command(&package_manager, script);
346 let id = format!("node:{script}");
347 let verification = if required {
348 VerificationCommand::required(id, kind, description, command)
349 } else {
350 VerificationCommand::optional(id, kind, description, command)
351 };
352 commands.push(verification);
353 }
354 }
355
356 if commands.is_empty() {
357 return None;
358 }
359
360 Some(VerificationPreset::new(
361 "node-default",
362 "node",
363 "Node.js package verification",
364 commands,
365 ))
366}
367
368fn detect_node_package_manager(workspace: &Path, package: &serde_json::Value) -> String {
369 if let Some(manager) = package

Callers 1

Calls 4

node_script_commandFunction · 0.85
getMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected