Skip to content

Instantly share code, notes, and snippets.

@abepetrillo
Last active April 6, 2016 22: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 abepetrillo/1c2deae560e8170b4e6374da18f7b240 to your computer and use it in GitHub Desktop.
Save abepetrillo/1c2deae560e8170b4e6374da18f7b240 to your computer and use it in GitHub Desktop.
Move old components to the new pod structure encouraged by ember-cli
var fs = require('fs'),
path = require('path');
function walkSync(currentDirPath, callback) {
fs.readdirSync(currentDirPath).forEach(function (name) {
var filePath = path.join(currentDirPath, name);
var stat = fs.statSync(filePath);
if (stat.isFile()) {
callback(filePath, stat);
} else if (stat.isDirectory()) {
//walkSync(filePath, callback);
}
});
}
function moveTemplate(file) {
console.log(file);
var fileName = file.split('/')[3].split('.')[0];
fs.mkdir(`./app/pods/components/${fileName}`, console.log);
fs.rename(file, `./app/pods/components/${fileName}/template.hbs`, console.log);
}
function moveComponent(file) {
console.log(file);
var fileName = file.split('/')[2].split('.')[0];
fs.mkdir(`./app/pods/components/${fileName}`, console.log);
fs.rename(file, `./app/pods/components/${fileName}/component.js`, console.log);
}
walkSync('./app/components', moveComponent);
walkSync('./app/templates/components', moveTemplate);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment