Created
November 29, 2018 10:11
-
-
Save mubaidr/be7310d26c885162f627343363125cda 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 fs = require('fs'); | |
const Replace = require('replace'); | |
const basePath = './api/'; | |
const modelsPath = './api/db/models/'; | |
const models = fs.readdirSync(modelsPath); | |
models.forEach(model => { | |
const splitted = model | |
.replace('.js', '') | |
.toLowerCase() | |
.split('_'); | |
if (splitted.length > 1) { | |
const find = splitted | |
.map((s, i) => { | |
if (i === 0) return s; | |
return s[0].toUpperCase() + s.substr(1); | |
}) | |
.join(''); | |
splitted.shift(); | |
const replace = splitted | |
.map((s, i) => { | |
if (i === 0) return s; | |
return s[0].toUpperCase() + s.substr(1); | |
}) | |
.join(''); | |
// console.log(find, replace); | |
Replace({ | |
regex: find, | |
replacement: replace, | |
paths: ['./api/'], | |
recursive: true, | |
silent: true, | |
include: '*.js', | |
q: true, | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment