var lineReader = require('readline').createInterface({
input: require('fs').createReadStream('dev/app.scss')
});
-String.prototype.stringFromToken = function(position, token, lastToken = false){
+String.prototype.stringFromToken = function(position, token, lastToken = false, string = false){
+ let length = 1;
+ if(string) length = token.length;
+
if(lastToken && position === 'before'){
return this.substr(0, this.lastIndexOf(token))
}else if(lastToken && !postition === 'before'){
- return this.substr(this.lastIndexOf(token) + 1);
+ return this.substr(this.lastIndexOf(token) + length);
}else {
if(position === 'before'){
return this.substr(0, this.indexOf(token))
}else{
- return this.substr(this.indexOf(token)+1)
+ return this.substr(this.indexOf(token)+length)
}
}
}
let mods = [];
fs.readdir(fullPath, function(err, item) {
item.forEach(function(modName){
- mods.push({name: modName, active: true, path: `${fullPath}/${modName}`});
+ let reference = `${fullPath}/${modName}`.stringFromToken('after',"dev/", false, true);
+ mods.push({
+ name: modName,
+ active: true,
+ path: `${fullPath}/${modName}`,
+ sass: `${reference}/${modName}`,
+ functions: `${reference}/functions/${modName}.php`,
+ reference:reference
+ });
});
storeModules(setModules(modType,mods));
});