mirror of
https://github.com/harish2704/file-header.git
synced 2026-09-10 15:11:07 +00:00
* Readme
* V0.1.0
This commit is contained in:
@@ -1,2 +1,65 @@
|
|||||||
# file-header
|
# file-header
|
||||||
A template based commandline file-header generator
|
A CLI tool for generating file header from a configuration file and an EJS template.
|
||||||
|
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
#### install the package
|
||||||
|
`npm i -g file-header`
|
||||||
|
|
||||||
|
#### Edit the config file ( Optional )
|
||||||
|
Data to be presented on a file header is stored in a config file which is located at `~/.file-headers/template_data.js`
|
||||||
|
|
||||||
|
The default content of this file will be as follows.
|
||||||
|
```javascript
|
||||||
|
module.exports = {
|
||||||
|
user: process.env.USER,
|
||||||
|
email: process.env.USER + '@' + process.env.HOST,
|
||||||
|
date: new Date(),
|
||||||
|
};
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
We can customize it as required. For example, change it to
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
module.exports = {
|
||||||
|
user: 'Jake sully'
|
||||||
|
email: 'gmail@jakesully.com'
|
||||||
|
github: 'https://github.com/jakesully'
|
||||||
|
date: new Date(),
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Edit the [EJS](ejs) tempalte of the default file-header ( Optional )
|
||||||
|
|
||||||
|
The default file header template can be found at `~/.file-headers/default`
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Commandline
|
||||||
|
```
|
||||||
|
file-header <filename.ext>
|
||||||
|
```
|
||||||
|
which will print the file header to your console.
|
||||||
|
|
||||||
|
|
||||||
|
#### Use with Vim editor
|
||||||
|
|
||||||
|
Add the below line to your vim config file
|
||||||
|
```vim
|
||||||
|
command! Header :execute '0r!file-header %'
|
||||||
|
```
|
||||||
|
|
||||||
|
Now, type `:Header` to add file header to your current buffer.
|
||||||
|
|
||||||
|
[ejs]: https://github.com/mde/ejs "Ejs template engine"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* <%- filename %>
|
* <%- filename %>
|
||||||
|
* Created at: <%- date %>
|
||||||
*
|
*
|
||||||
* Copyright <%- new Date().getFullYear() %> <%- user %> <<%- email %>>
|
* Copyright <%- date.getFullYear() %> <%- user %> <<%- email %>>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
+8
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "file-header",
|
"name": "file-header",
|
||||||
"version": "0.0.1",
|
"version": "0.1.0",
|
||||||
"description": "",
|
"description": "A CLI tool for generating file header from a configuration file and an EJS template.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"name": "Harish.K",
|
"name": "Harish.K",
|
||||||
"email": "harish2704@gmail.com"
|
"email": "harish2704@gmail.com"
|
||||||
},
|
},
|
||||||
"license": "ISC",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ejs": "^2.5.3"
|
"ejs": "^2.5.3"
|
||||||
},
|
},
|
||||||
@@ -24,5 +24,10 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/harish2704/file-header/issues"
|
"url": "https://github.com/harish2704/file-header/issues"
|
||||||
},
|
},
|
||||||
|
"keywords": [
|
||||||
|
"file-header",
|
||||||
|
"ejs",
|
||||||
|
"cli"
|
||||||
|
],
|
||||||
"homepage": "https://github.com/harish2704/file-header#readme"
|
"homepage": "https://github.com/harish2704/file-header#readme"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user