* Support for multiple extensions line "*.spec.js", "*.model.js" etc

This commit is contained in:
2017-05-26 17:28:54 +05:30
parent 6daf54d1b3
commit b1efa6c5bc
3 changed files with 7 additions and 3 deletions
+2 -1
View File
@@ -38,7 +38,8 @@ It is just [EJS](ejs) template. We can customize it to any extend.
If we require different template for each file type , create a file `~/.file-headers/<extention>`
For javscript, create a custom template at `~/.file-headers/js` and customize it.
* For javscript, create a custom template at `~/.file-headers/js` and customize it.
* If we want a custom header for '*.spec.js' file, create ~/.file-headers/spec.js and customize it
## Usage
Regular → Executable
+4 -1
View File
@@ -22,10 +22,13 @@ function initialize(){
function getTemplate( fname ){
var ext = path.extname(fname).slice(1) || 'default';
var match = fname.match(/\.(.*)/);
var ext = match ? match[1] : fname;
if( fs.existsSync( path.join(configDir, ext ) ) ){
return fs.readFileSync( path.join(configDir, ext ), 'utf-8' );
} else if( ext.indexOf('.') !== -1 ){
return getTemplate( ext );
} else {
return fs.readFileSync( path.join(configDir, 'default' ), 'utf-8' );
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "file-header",
"version": "0.1.0",
"version": "0.1.1",
"description": "A CLI tool for generating file header from a configuration file and an EJS template.",
"main": "index.js",
"scripts": {