Created
March 17, 2020 02:23
-
-
Save shisama/5d9cfebf986f29edb814b7549d5a9583 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 path = require('path'); | |
const fs = require('fs'); | |
const { promisify } = require('util'); | |
const glob = promisify(require('glob')); | |
const FROM = '.css'; | |
const TO = '.scss'; | |
const mv = async file => { | |
const out = `${path.join( | |
path.dirname(file), | |
path.basename(file, FROM) | |
)}${TO}`; | |
const buf = await fs.promises.readFile(file); | |
await fs.promises.writeFile(out, buf); | |
await fs.promises.unlink(file); | |
}; | |
(async () => { | |
const files = await glob(path.resolve(__dirname, `**/*${FROM}`)); | |
const promises = []; | |
for (const file of files) { | |
promises.push(mv(file)); | |
} | |
Promise.all(promises); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment