Last active
April 6, 2016 22:23
-
-
Save abepetrillo/1c2deae560e8170b4e6374da18f7b240 to your computer and use it in GitHub Desktop.
Move old components to the new pod structure encouraged by ember-cli
This file contains 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
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