Skip to content

Instantly share code, notes, and snippets.

@kimmellj
Created August 22, 2019 21:24
Show Gist options
  • Save kimmellj/ec158e0b2d53815e613815e53a8e5712 to your computer and use it in GitHub Desktop.
Save kimmellj/ec158e0b2d53815e613815e53a8e5712 to your computer and use it in GitHub Desktop.
const fs = require('fs');
const fileContents = fs.readFileSync(process.argv[2]).toString();
const regex = /\$[A-Za-z\-]*:/g;
let matches;
let variables = [];
while ((matches = regex.exec(fileContents)) !== null) {
const match = matches[0];
if (variables.indexOf(match) > -1) {
console.log(`Duplicate variable: ${match}`);
} else {
variables.push(match);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment