Skip to content

Commit

Permalink
Added additional logging, and better comments
Browse files Browse the repository at this point in the history
  • Loading branch information
confused-Techie committed Oct 17, 2023
1 parent 88aaaca commit 764d80c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions script/validate-wasm-grammar-prs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const fs = require("node:fs");
const CSON = require("season");

// Change this if you want more logs
let verbose = false;
let verbose = true;

// Lets first find our common ancestor commit
// This lets us determine the commit where the branch or fork departed from
Expand Down Expand Up @@ -99,12 +99,15 @@ for (const wasmFile of wasmFilesChanged) {

if (getPrevFile.status !== 0 || getPrevFile.stderr.toString().length > 0) {
// This can fail for two major reasons
// 1. It actually failed
// 2. This is a new file, and it failed to find an earlier one that didn't exist
// 1. The `git show` command has returned an error code other than `0`, failing.
// 2. This is a new file, and it failed to find an earlier copy (which didn't exist)
// So that we don't fail brand new TreeSitter grammars, we manually check for number 2

if (getPrevFile.stderr.toString().includes("exists on disk, but not in")) {
// Looks like this file is new. Skip this check
if (verbose) {
console.log("Looks like this file is new. Skipping...");
}
continue;
}

Expand Down Expand Up @@ -135,6 +138,10 @@ for (const wasmFile of wasmFilesChanged) {

// Else it looks like it has been updated properly
console.log(`Validated \`parserSource\` has been updated within '${filePath}' properly.`);
} else {
if (verbose) {
console.log("This grammar file doesn't use a WASM file that's changed (On the current interation)");
}
}
}
}
Expand Down

0 comments on commit 764d80c

Please sign in to comment.