Skip to content

Instantly share code, notes, and snippets.

View welingtonms's full-sized avatar

Welington Silva welingtonms

View GitHub Profile
const fs = require('fs');
const path = require('path');
// Get command line arguments
const [oldExt, newExt, targetDir] = process.argv.slice(2);
if (!oldExt || !newExt) {
console.error(
'Usage: node rename-extensions.js <old-extension> <new-extension> [directory]',
);
function flatten(array) {
let flattened = [];
for (let i = 0; i < array.length; i++) {
if (Array.isArray(array[i])) {
flattened = flattened.concat(flatten(array[i]))
} else {
flattened.push(array[i])
}
}