Browse Source

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

master 0.1.1
Harish.K 8 years ago
parent
commit
b1efa6c5bc
  1. 3
      README.md
  2. 5
      main.js
  3. 2
      package.json

3
README.md

@ -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

5
main.js

@ -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' );
}

2
package.json

@ -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": {

Loading…
Cancel
Save