Last active
October 7, 2022 21:45
-
-
Save lostPixels/04eb5edec444e346168989be3f1a8513 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const replace = require('replace-in-file'); | |
let files = 'dist/main.js'; //Add your sketch file here. | |
let from = [ //Add your keywords that you want to replace here! | |
/grainHigh/g, | |
/grainLow/g, | |
/shadowColor/g, | |
] | |
const alpha = Array.from(Array(26)).map((e, i) => i + 65); | |
const alphabet = alpha.map((x) => String.fromCharCode(x)); | |
let to = []; | |
let letterCount = 0; | |
let letterStep = 0; | |
for (let i = 0; i < from.length; i++) { | |
let lt = alphabet[letterStep] + letterCount; | |
to.push(lt); | |
letterCount++; | |
if (letterCount > 9) { | |
letterCount = 0; | |
letterStep++; | |
} | |
} | |
const options = { | |
files, | |
from, | |
to, | |
}; | |
replace(options) | |
.then(results => { | |
console.log('Replacement results:', results); | |
}) | |
.catch(error => { | |
console.error('Error occurred:', error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment