Skip to content

Commit 2af7480

Browse files
author
Edgar Vaguencia
committed
📚 Incorporación de ejemplo y mejora en documentos permitidos
1 parent 091651c commit 2af7480

7 files changed

+37
-17
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#logs
2+
*.log

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
node_js:
3+
-0.10.36

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
replaceWord
22
===========
33

4+
[![Code Climate](https://codeclimate.com/github/EdgarVaguencia/replaceWord/badges/gpa.svg)](https://codeclimate.com/github/EdgarVaguencia/replaceWord)
5+
46
Valida la correcta sintaxis de inicio de bloque de PHP (<? to <?php) para archivos HTML, PHP, JS, Python
57

68
# Install

appPhpSyntax.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
#!/usr/bin/env node
22

3-
var fs = require('fs'),
4-
path = require('path');
3+
var fs = require('fs');
4+
var path = require('path');
55

66
// Lectura de parametros pasados e inicializamos variables requeridas
7-
var options = process.argv.slice(2),
8-
dir,
9-
ext = ['html','js','py','php'],
10-
regexp = /(<\?)(\W|$)/g;
7+
var options = process.argv.slice(2);
8+
var dir;
9+
var ext = ['html','js','py','php'];
10+
var regexp = /(<\?)(\W|$)/g;
1111

1212
//Asignamos la ruta del directoria según los parametros o se asigna la actual
1313
if ( options.length >= 1 ) {
1414
dir = options[0];
1515
}else{
1616
dir = '.';
17-
};
17+
}
1818

1919
//Llamada inical a la lectura del directorio
2020
readDir(dir+path.sep);
@@ -29,14 +29,14 @@ function readDir (dirpath) {
2929
readDir(dirpath+file+path.sep);
3030
}
3131
if( stats && stats.isFile() ){
32-
var type = file.split('.')[1];
33-
if ( ext.indexOf(type) >=0 && file.split('.').length == 1 ) {
32+
var type_ = file.split('.');
33+
if (ext.indexOf(type_[type_.length - 1]) >= 0) {
3434
readfile(dirpath+file);
35-
};
36-
};
35+
}
36+
}
3737
});
3838
});
39-
};
39+
}
4040
});
4141
}
4242

@@ -50,13 +50,13 @@ function readfile (filepath) {
5050
if ( re ) {
5151
lines[i] = lines[i].replace(regexp,re[0].trim()+"php ","gi");
5252
flag = true;
53-
};
54-
};
53+
}
54+
}
5555
if (flag) {
5656
data = lines.join('\n');
5757
fs.writeFile(filepath,data,function(err){
5858
if (err) throw err;
5959
console.log(filepath+" Saved!");
60-
})
61-
};
60+
});
61+
}
6262
}

example/archivo.php

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?
2+
echo "Esto es PHP";
3+
?>

example/archivo.test.php

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?
2+
echo 'Este es una prueba con archvio con doble punto';
3+
?>

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "phpsyntax",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "Validación que todo los archivos del proyecto en PHP contengan la sintaxis correcta",
55
"main": "appPhpSyntax.js",
66
"keywords": [
@@ -9,6 +9,13 @@
99
"bin":{
1010
"phpsyntax" : "./appPhpSyntax.js"
1111
},
12+
"scripts": {
13+
"test": "node appPhpSyntax.js example/"
14+
},
15+
"repository": {
16+
"type" : "git",
17+
"url" : "https://github.com/EdgarVaguencia/replaceWord.git"
18+
}
1219
"author": "Edgar Valencia <isc.edgarvalencia@gmail.com>",
1320
"license": "MIT"
1421
}

0 commit comments

Comments
 (0)