1 Commits
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>` 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 ## Usage
Regular → Executable
+4 -1
View File
@@ -22,10 +22,13 @@ function initialize(){
function getTemplate( fname ){ 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 ) ) ){ if( fs.existsSync( path.join(configDir, ext ) ) ){
return fs.readFileSync( path.join(configDir, ext ), 'utf-8' ); return fs.readFileSync( path.join(configDir, ext ), 'utf-8' );
} else if( ext.indexOf('.') !== -1 ){
return getTemplate( ext );
} else { } else {
return fs.readFileSync( path.join(configDir, 'default' ), 'utf-8' ); return fs.readFileSync( path.join(configDir, 'default' ), 'utf-8' );
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "file-header", "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.", "description": "A CLI tool for generating file header from a configuration file and an EJS template.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {