Skip to content

Commit

Permalink
Fix paths
Browse files Browse the repository at this point in the history
  • Loading branch information
silverreve23 committed Feb 27, 2018
1 parent c6e41b8 commit c0910ec
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 18 deletions.
4 changes: 2 additions & 2 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"in" : "../pphpapp/app",
"out" : "../pphpapp/out"
"in" : "pphpapp/app",
"out" : "pphpapp/out"
}
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('SBKInfo Pphp');
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "pphp",
"version": "1.0.0",
"description": "PHP Preprocossor",
"main": "index.js",
"scripts": {
"live": "node system/processor.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/silverreve23/pphp.git"
},
"keywords": [
"pphp",
"npm",
"sbkinfo"
],
"author": "Svyatoslav <silverreve23@gmail.com>",
"license": "GPL-3.0",
"bugs": {
"url": "https://github.com/silverreve23/pphp/issues"
},
"homepage": "https://github.com/silverreve23/pphp#readme"
}
52 changes: 36 additions & 16 deletions system/processor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var fs = require('fs');
var mkdirp = require('mkdirp');

var dirRoot = '../';
var isError = false;

var dirRoot = '../../';

var sleepTime = 2000;

Expand All @@ -28,19 +30,35 @@ console.log(
+ 's\x1b[0m'
);

//setInterval(
// checkChangeFiles,
// sleepTime
//);
var idInterval = setInterval(
checkChangeFiles,
sleepTime
);

checkChangeFiles();

function checkChangeFiles(dirScan = null){

if(!dirScan)
dirScan = dirRoot + config.in;
dirScan = __dirname + '/' + dirRoot + config.in;

fs.readdir(dirScan, function(err, items){

if(err){

isError = err;

clearInterval(idInterval);

console.log(
"\x1b[41mError: "
+ err.code
+ ' code\x1b[0m'
);

return false;

}

for(var i = 0; i < items.length; i++){

Expand Down Expand Up @@ -74,10 +92,10 @@ function isChangeFile(file){

scanFilesTime[file] = fileTime;

dirParse(dirRoot + config.in);
dirParse(__dirname + '/' + dirRoot + config.in);

console.log(
'\n\x1b[33m\t'
'\x1b[33m\t'
+ file
+ ' changed!'
);
Expand Down Expand Up @@ -142,12 +160,12 @@ function parseFile($filePath){
});

// Pares [function] word
line = line.replace(/\@function(\(static\))?\s*([\+|\-|\.])\s*(\w+)\s*\([$|\w|\s|,]*\)/, function(findedStr, static, access){
line = line.replace(/\@def(\(static\))?\s*([\+|\-|\.])\s*(\w+)\s*\([$|\w|\s|,]*\)/, function(findedStr, static, access){

if(static)
return accesseVals[access] + ' static function' + findedStr.substr(18) + "{";
return accesseVals[access] + ' static function' + findedStr.substr(13) + "{";

return accesseVals[access] + ' function' + findedStr.substr(10) + "{";
return accesseVals[access] + ' function' + findedStr.substr(5) + "{";

});

Expand Down Expand Up @@ -203,16 +221,18 @@ function parseFile($filePath){
var pathOut = null;
var pathMake = null;

fileOut = $filePath.replace(dirRoot + config.in + '/', '');
pathOut = dirRoot + config.out + '/';
fileOut = pathOut + fileOut;
pathMake = fileOut.replace(/\/\w{1,}\.php$/, '');
fileOut = $filePath.replace(
config.in,
config.out
);

console.log();
fileOut = fileOut.replace(/.blade/, '');
pathMake = fileOut.replace(/\/\w{1,}\.php$/, '');

if(!newFileData)
return false;


mkdirp(pathMake, (err) => {

if(err) return err;
Expand Down

0 comments on commit c0910ec

Please sign in to comment.