Comparing version 1.0.5 to 1.0.6
@@ -7,9 +7,10 @@ #! /usr/bin/env node | ||
// Load dependencies | ||
var fs = require('fs'), | ||
var fs = require('fs.extra'), | ||
path = require('path'), | ||
colors = require('colors'), | ||
omelette = require("omelette"); | ||
omelette = require("omelette"), | ||
config = require('../config/config.json'); | ||
// Paths | ||
var tplDirName = '.templates'; | ||
var tplDirName = config.TPL_DIR; | ||
var tplDir = path.join(getUserHome(), tplDirName); | ||
@@ -27,3 +28,3 @@ | ||
// Work | ||
// DO STUFF | ||
if (process.argv[2] === 'list') { | ||
@@ -33,2 +34,4 @@ return list(tplDir, true); | ||
return usage(); | ||
} else if (process.argv[2] === 'init') { | ||
return init(tplDir); | ||
} else { | ||
@@ -46,2 +49,22 @@ return mk(tplDir); | ||
/** | ||
* init | ||
*/ | ||
function init(dir) { | ||
fs.mkdir(dir, function (err) { | ||
if (!err) { | ||
var baseTpls = fs.readdirSync('../templates/'); | ||
baseTpls.forEach(function (file) { | ||
console.log('FILE: ',path.join(dir, file)); | ||
fs.copy('../templates/' + file, path.join(dir, file), function (err) { | ||
if (err) { | ||
console.log('Ooops! Some errors occurred upon attempt to create example files in: '.red.bold + dir); | ||
} | ||
}); | ||
}); | ||
console.log('Example template files copied to ' + dir.green.bold + ' directory'); | ||
} | ||
}); | ||
} | ||
/** | ||
* list | ||
@@ -111,3 +134,5 @@ * @param dir | ||
"mkhere: Create files based on predefined templates".white.bold + BR + | ||
"--------------------------------------------------" + BR + | ||
"--------------------------------------------------" + BR + BR + | ||
"Run: ".white + "mkhere init ".green.bold + BR + | ||
"\t To create " + tplDirName.italic + " directory within your home containing sample templates." + BR + | ||
"Run: ".white + "mkhere list ".green.bold + BR + | ||
@@ -118,3 +143,3 @@ "\t To list all templates in " + tplDir.italic + BR + | ||
"Run: ".white + "mkhere html.html ~/Desktop/sa ".green.bold + BR + | ||
"\t This will create new file " + "sa.html".italic + " based on " + path.join(tplDir, "html.html").italic + " on the desktop" + BR + | ||
"\t This will create new file " + "sa.html".italic + " based on " + path.join(tplDir, "html.html").italic + " on the desktop" + BR + BR + | ||
"------------------Auto-completion-----------------" + BR + BR + | ||
@@ -121,0 +146,0 @@ "Run: " + "mkhere --completion >> ~/.mkhere.completion.sh && echo 'source ~/.mkhere.completion.sh' >> ~/.bashrc".green.bold + BR + |
{ | ||
"name": "mkhere", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Make files based on template", | ||
@@ -5,0 +5,0 @@ "main": "lib/mkhere.js", |
@@ -9,10 +9,20 @@ # mkhere | ||
`mkhere list` - List all templates in _USER_HOME_DIR/.templates/_ | ||
-------------------------------------------------- | ||
mkhere: Create files based on predefined templates | ||
-------------------------------------------------- | ||
`mkhere help` - Show usage/help | ||
Run: mkhere init | ||
To create .templates directory within your home containing sample templates. | ||
Run: mkhere list | ||
To list all templates in /home/sasha/.templates | ||
Run: mkhere tplname.html newname | ||
This will create new file newname.html based on /home/sasha/.templates/tplname.html in current directory | ||
Run: mkhere html.html ~/Desktop/sa | ||
This will create new file sa.html based on /home/sasha/.templates/html.html on the desktop | ||
`mkhere tplname.html newname` - Create new file _newname.html_ based on _USER_HOME_DIR/Templates/tplname.html_ in current working directory | ||
------------------Auto-completion----------------- | ||
### Auto-completion | ||
Run: `mkhere --completion >> ~/.mkhere.completion.sh && echo 'source ~/.mkhere.completion.sh' >> .bashrc` In order to enable auto-completion in your __bash__ terminal, or `echo '. <(./githubber --completion)' >> .zshrc` if you're using __zsh__ | ||
Run: mkhere --completion >> ~/.mkhere.completion.sh && echo 'source ~/.mkhere.completion.sh' >> ~/.bashrc | ||
In order to enable auto-completion in your `BASH` terminal | ||
Or: echo '. <(./githubber --completion)' >> .zshrc | ||
if you're using `ZSH` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10672
9
138
27