iron-fe
Version:
An opinionated - yet flexible - front end development framework for use with Adobe Experience Manager
49 lines (34 loc) • 1.26 kB
JavaScript
var fs = require('fs');
var shell = require('shelljs');
var pathToProjectRoot = require('./pathToProjectRoot');
module.exports = {
init : function(){
var config = require('rc')('iron', {
defaultComponents : {},
projectPath : "",
templates : {}
});
var rcResult = {};
rcResult.exists = config.configs ? true : false;
if( rcResult.exists ){
var configProps = ["config", "configs"];
rcResult.config = config;
configProps.filter(function(prop) {
if (rcResult.config.hasOwnProperty(prop))
delete rcResult.config[prop];
});
}
return rcResult;
},
update : function( updatedRc, runFromIronFolder ){
console.log(pathToProjectRoot());
if( runFromIronFolder ){
shell.cd( '..' );
}
if( updatedRc._ ) delete updatedRc._;
if( updatedRc.s ) delete updatedRc.s;
if( updatedRc.configs ) delete updatedRc.configs;
if( updatedRc.config ) delete updatedRc.config;
fs.writeFileSync( '.ironrc', JSON.stringify( updatedRc, {}, 4 ) );
}
}