Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mkhere

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mkhere - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

110

lib/mkhere.js
#! /usr/bin/env node
'use strict';
(function () {
var fs = require('fs');
var path = require('path');
var colors = require('colors');
'use strict';
var tplDir = path.join(getUserHome(), '.templates');
var BR = "\r\n";
var fs = require('fs'),
path = require('path'),
colors = require('colors'),
omelette = require("omelette");
if (process.argv[2] === 'list') {
return list(tplDir);
} else if (process.argv[2] === 'help') {
return usage();
} else {
return mk(tplDir);
}
var complete = omelette("mkhere <action>");
function getUserHome() {
return process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
}
function list(dir) {
var tpls = fs.readdirSync(dir);
tpls.forEach(function (file) {
console.log(file);
complete.on("action", function () {
return this.reply(["list", "help"]);
});
}
complete.init();
function usage() {
console.log(
BR + "mkhere: Create files based on predefined emplates".inverse + BR + BR +
"mkhere list ".green.bold + BR +
"\t List all templates in " + tplDir.italic + BR +
"mkhere tplname.html newname ".green.bold + BR +
"\t Will create new file " + "newname.html".italic + " based on " + path.join(tplDir, "tplname.html").italic + " in current directory"
);
}
var tplDir = path.join(getUserHome(), '.templates');
var BR = "\r\n";
function mk(tplDir) {
var CWD = process.cwd();
var tplFile = process.argv[2];
var tplName = path.join(tplDir, tplFile);
var newFileExt = tplFile.slice(tplFile.indexOf('.'));
var newFile = process.argv[3] + newFileExt;
fs.readFile(tplName, 'utf8', function (err, data) {
if (err) {
return console.log(
'Error! No such template file '.red + tplFile.red.bold + ' in '.red + tplDir.red + BR +
if (process.argv[2] === 'list') {
return list(tplDir);
} else if (process.argv[2] === 'help' || !process.argv[2]) {
return usage();
} else {
return mk(tplDir);
}
function getUserHome() {
return process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
}
function list(dir) {
var tpls = fs.readdirSync(dir);
tpls.forEach(function (file) {
console.log(file);
});
}
function usage() {
console.log(
"--------------------------------------------------" + BR +
"mkhere: Create files based on predefined templates".white.bold + BR +
"--------------------------------------------------" + BR +
"Run: ".white + "mkhere list ".green.bold + BR +
"\t To list all templates in " + tplDir.italic + BR +
"Run: ".white + "mkhere tplname.html newname ".green.bold + BR +
"\t This will create new file " + "newname.html".italic + " based on " + path.join(tplDir, "tplname.html").italic + " in current directory" + BR + BR +
"------------------Auto-completion-----------------" + BR + BR +
"Run: " + "mkhere --completion >> ~/.mkhere.completion.sh && echo 'source ~/.mkhere.completion.sh' >> .bash_profile".green.bold + BR +
"\tIn order to enable auto-completion in your `BASH` terminal" + BR +
"Or: " + "echo '. <(./githubber --completion)' >> .zshrc".green.bold + BR +
"\tif you're using `ZSH`"
);
}
function mk(tplDir) {
var CWD = process.cwd();
var tplFile = process.argv[2];
var tplName = path.join(tplDir, tplFile);
var newFileExt = tplFile.slice(tplFile.indexOf('.'));
var newFile = process.argv[3] + newFileExt;
fs.readFile(tplName, 'utf8', function (err, data) {
if (err) {
return console.log(
'Error! No such template file '.red + tplFile.red.bold + ' in '.red + tplDir.red + BR +
"For usage see: " + "mkhere help".bold
);
}
fs.writeFile(path.join(CWD,newFile), data);
});
}
);
}
fs.writeFile(path.join(CWD, newFile), data);
});
}
}).call(this);
{
"name": "mkhere",
"version": "1.0.2",
"version": "1.0.3",
"description": "Make files based on template",

@@ -37,3 +37,3 @@ "main": "lib/mkhere.js",

"colors": "~0.6.2",
"path": "~0.4.9"
"omelette": "~0.1.0"
},

@@ -40,0 +40,0 @@ "engines": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc