Skip to content

Instantly share code, notes, and snippets.

@shisama
Created March 17, 2020 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shisama/5d9cfebf986f29edb814b7549d5a9583 to your computer and use it in GitHub Desktop.
Save shisama/5d9cfebf986f29edb814b7549d5a9583 to your computer and use it in GitHub Desktop.
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