mirror of
https://github.com/harish2704/file-header.git
synced 2026-09-10 07:01:07 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1efa6c5bc |
@@ -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
|
||||||
|
|||||||
@@ -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
@@ -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": {
|
||||||
|
|||||||
Reference in New Issue
Block a user