Skip to content

Instantly share code, notes, and snippets.

@Williammer
Created November 19, 2018 03:31
Show Gist options
  • Save Williammer/4c57a83a38165e228e348d9742dba70a to your computer and use it in GitHub Desktop.
Save Williammer/4c57a83a38165e228e348d9742dba70a to your computer and use it in GitHub Desktop.
const fs = require('fs');
function addSchemaName(basePath) {
const result = fs.readdirSync(basePath);
// console.log(result);
result.forEach((path) => {
if (path.startsWith('_') || path.endsWith('Schema.js')) { return; }
if (path.endsWith('.js')) {
const prefix = path.split('.')[0];
fs.renameSync(`${basePath}/${path}`, `${basePath}/${prefix}Schema.js`);
} else {
addSchemaName(`${basePath}/${path}`);
}
})
}
addSchemaName('.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment