Created
August 5, 2019 02:48
-
-
Save AndrewThian/01ead1a8301ff63e946a3a840af32fc7 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 argv = require('minimist')(process.argv.slice(2)); | |
const stats = require('./sass-colors'); | |
const readline = require('readline'); | |
const fs = require('fs'); | |
const rl = readline.createInterface({ | |
input: fs.createReadStream(argv.f), | |
console: false, | |
}); | |
const testcases = Object.keys(stats); | |
let file = ''; | |
let currentMatcher = null; | |
const handleMatcher = (line) => { | |
return testcases.some((v) => { | |
const truthy = line.indexOf(v) >= 0; | |
if (truthy) currentMatcher = v; | |
return truthy; | |
}); | |
}; | |
rl.on('line', (line) => { | |
if (handleMatcher(line)) { | |
const parsedLine = line.replace(currentMatcher, stats[currentMatcher]); | |
file += `${parsedLine} /*${currentMatcher}*/\n`; | |
} else { | |
file += `${line}\n`; | |
} | |
}); | |
rl.on('close', () => { | |
console.log(file); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment